4 * Use `Polymer.IronValidatableBehavior` to implement an element that validates user input.
8 * Changing the `invalid` property, either manually or by calling `validate()` will update the
9 * `aria-invalid` attribute.
11 * @demo demo/index.html
14 Polymer.IronValidatableBehavior = {
19 * Namespace for this validator.
27 * Name of the validator to use.
34 * True if the last call to `validate` is invalid.
38 reflectToAttribute: true,
50 '_invalidChanged(invalid)'
54 return this._validatorMeta && this._validatorMeta.byKey(this.validator);
58 this._validatorMeta = new Polymer.IronMeta({type: this.validatorType});
61 _invalidChanged: function() {
63 this.setAttribute('aria-invalid', 'true');
65 this.removeAttribute('aria-invalid');
70 * @return {boolean} True if the validator `validator` exists.
72 hasValidator: function() {
73 return this._validator != null;
77 * @param {Object} values Passed to the validator's `validate()` function.
78 * @return {boolean} True if `values` is valid.
80 validate: function(values) {
82 if (this.hasValidator()) {
83 valid = this._validator.validate(values);
86 this.invalid = !valid;