OLD | NEW |
1 | 1 |
2 | 2 |
3 /** | 3 /** |
4 * Use `Polymer.IronValidatableBehavior` to implement an element that validate
s user input. | 4 * Use `Polymer.IronValidatableBehavior` to implement an element that validate
s user input. |
5 * | 5 * |
6 * ### Accessiblity | 6 * ### Accessiblity |
7 * | 7 * |
8 * Changing the `invalid` property, either manually or by calling `validate()`
will update the | 8 * Changing the `invalid` property, either manually or by calling `validate()`
will update the |
9 * `aria-invalid` attribute. | 9 * `aria-invalid` attribute. |
10 * | 10 * |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 */ | 71 */ |
72 hasValidator: function() { | 72 hasValidator: function() { |
73 return this._validator != null; | 73 return this._validator != null; |
74 }, | 74 }, |
75 | 75 |
76 /** | 76 /** |
77 * @param {Object} values Passed to the validator's `validate()` function. | 77 * @param {Object} values Passed to the validator's `validate()` function. |
78 * @return {boolean} True if `values` is valid. | 78 * @return {boolean} True if `values` is valid. |
79 */ | 79 */ |
80 validate: function(values) { | 80 validate: function(values) { |
81 var valid = this._validator && this._validator.validate(values); | 81 var valid = true; |
| 82 if (this.hasValidator()) { |
| 83 valid = this._validator.validate(values); |
| 84 } |
| 85 |
82 this.invalid = !valid; | 86 this.invalid = !valid; |
83 return valid; | 87 return valid; |
84 } | 88 } |
85 | 89 |
86 }; | 90 }; |
87 | 91 |
OLD | NEW |