decide.nolog.cz/app/validators/valid-collection.js

22 lines
521 B
JavaScript
Raw Normal View History

import classic from 'ember-classic-decorator';
2015-11-18 17:49:01 +01:00
import BaseValidator from 'ember-cp-validations/validators/base';
@classic
export default class ValidCollectionValidator extends BaseValidator {
validate(value, options) {
if (options.active === false) {
return true;
}
2016-01-28 23:48:14 +01:00
const valid = value.every((element) => {
2015-11-18 17:49:01 +01:00
return element.get('validations.isValid');
});
if (valid) {
return true;
2016-01-28 23:48:14 +01:00
} else {
return this.createErrorMessage('validCollection', options, value);
}
2015-11-18 17:49:01 +01:00
}
}