2015-11-18 17:49:01 +01:00
|
|
|
import BaseValidator from 'ember-cp-validations/validators/base';
|
|
|
|
|
|
|
|
export default BaseValidator.extend({
|
2015-11-19 21:51:49 +01:00
|
|
|
validate(value, options) {
|
|
|
|
if (options.active === false) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-11-19 21:16:32 +01:00
|
|
|
var valid = value.every((element) => {
|
2015-11-18 17:49:01 +01:00
|
|
|
return element.get('validations.isValid');
|
|
|
|
});
|
2015-11-19 21:16:32 +01:00
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
return true;
|
2015-11-22 19:11:32 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return this.createErrorMessage('validCollection', options, value);
|
2015-11-19 21:16:32 +01:00
|
|
|
}
|
2015-11-18 17:49:01 +01:00
|
|
|
}
|
|
|
|
});
|