I am using ember-cp-validation in ember js application for validation. using validate() method in components page. but i am getting error(validate is not a function). I referred this link
In models page,
import DS from 'ember-data';
import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
name: validator('presence', true),
address:[
validator('presence', true),
validator('length', { max: 300}),
],
pincode: validator('presence', true),
email:[
validator('presence', true),
validator('format', {type:'email'})
]
});
export default DS.Model.extend(Validations,{
name: DS.attr('string'),
address: DS.attr('string'),
pincode: DS.attr('number'),
email: DS.attr('string')
});
And Components page,
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
authenticate() {
let profile = this.get('profile');
profile.validate().then(({ validations }) => {
if(validations.get('isValid')){
this.transitionToRoute("welcome");
}
});
}
}
});
Aucun commentaire:
Enregistrer un commentaire