The validate binding behavior enables quick and easy validation for two-way data-bindings. The behavior registers the binding instance with a controller, enabling the system to validate the binding's associated property when the validate trigger occurs (blur / change). The binding behavior is able to identify the object and property name to validate in all sorts of binding expressions :
Automatic Binding Validation :
<input type="text" value.bind="firstName & validate">
<input type="text" value.bind="person.firstName & validate">
<input type="text" value.bind="person['firstName'] | upperCase & validate">
<input type="text" value.bind="currentEntity[p] & debounce & validate">
validate accepts a couple of optional arguments enabling you to explicitly specify the rules and controller instance:
Explicit Binding Validation :
<input type="text" value.bind="firstName & validate:personController">
<input type="text" value.bind="firstName & validate:personRules">
<input type="text" value.bind="firstName & validate:personController:personRules">
The validate binding behavior obeys the associated controller's validateTrigger (blur, focusout, change, changeOrBlur, changeOrFocusout, manual). If you'd like to use a different validateTrigger in a particular binding use one of the following binding behaviors in place of & validate :
* & validateOnBlur : the DOM blur event triggers validation.
* & validateOnFocusout : the DOM focusout event triggers validation.
* & validateOnChange : data entry that changes the model triggers validation.
* & validateOnChangeOrBlur : DOM blur or data entry triggers validation.
* & validateOnChangeOrFocusout : DOM focusout or data entry triggers validation.
* & validateManually : the binding is not validated automatically when the associated element is blurred or changed by the user.