lcoq / ember-validations

Ember-Validations - An Ember.js library for handling object validations
MIT License
122 stars 25 forks source link

isValid on individual properties #18

Closed gpoitch closed 11 years ago

gpoitch commented 11 years ago

Maybe im missing something obvious that is already available, but I'd like to bind to the validity of each property.

For example, to add an error class to a text field:

{{view Ember.TextField valueBinding="content.username" classNameBinding="content.validationErrors.username.isValid::error}}

Thanks, and great work!

gpoitch commented 11 years ago

I got it working by just checking if it exists.

{{view Ember.TextField valueBinding="content.username" classNameBindings="content.validationErrors.username:error}}
akaravashkin commented 11 years ago

If you will use .validateProperty('username') instead of overall .validate() - your 'error' class will be still presented on the field, because content.validationErrors.username lives after .validateProperty(). So better to use content.validationErrors.username.length. It helps me and I hope this thought will help someone.