I am using this component for validation. http://ift.tt/1NRGKRu
I created the custom validator in dependent-state.js
import BaseValidator from 'ember-cp-validations/validators/base';
import LengthValidator from 'ember-cp-validations/validators/length';
import validator from 'ember-cp-validations';
export default BaseValidator.extend({
validate(value, options, model, attribute) {
if (model.get('country') !== 'US') {
return true;
}
else {
// return LengthValidator.validate(value, options, model, attribute);
// return new LengthValidator(value, options, model, attribute);
return validator('length', options);
}
}
});
Here I would like to call default 'length' validator, but all of above code fails. Any help?
And I use this custom validator in another file.
state: {
description: "State",
validators: [
validator('ds-error'),
validator('presence', true),
validator('dependent-state', { max: 2 }),
]
},
Aucun commentaire:
Enregistrer un commentaire