-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
ember-data 3.28, ember-model-validator 4.8
export default class MyModel extends Model {
@attr('string') name;
@belongsTo('category') category;
validations = {
name: {
presence: { message: 'Please enter name' },
},
category: {
presence: { message: 'Please select a category' },
},
};
}If you run validation when nothing is entered, errors will appear on 2 input fields. When you start entering a name, the error on the name will disappear automatically. But when you select a category, you need to run validation again for the error to disappear.
Is it possible to validate automatically?
Now I'm using notifyPropertyChange function to solve this issue in my common model like this:
notifyPropertyChange(key) {
super.notifyPropertyChange(key);
if (this.get(`errors.${key}`)) {
this.validate();
}
}Metadata
Metadata
Assignees
Labels
No labels