Index: polymer_1.2.3/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
diff --git a/polymer_1.0.4/bower_components/iron-validatable-behavior/iron-validatable-behavior.html b/polymer_1.2.3/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
similarity index 51% |
copy from polymer_1.0.4/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
copy to polymer_1.2.3/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
index c59c47e27d1131ed637aa3fa1607f5ff924ccd75..8060713913cdd9cce1462cdaa1b9507290468d87 100644 |
--- a/polymer_1.0.4/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
+++ b/polymer_1.2.3/bower_components/iron-validatable-behavior/iron-validatable-behavior.html |
@@ -14,9 +14,22 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
<script> |
/** |
- * Use `Polymer.IronValidatableBehavior` to implement an element that validates user input. |
+ * `Use Polymer.IronValidatableBehavior` to implement an element that validates user input. |
+ * Use the related `Polymer.IronValidatorBehavior` to add custom validation logic to an iron-input. |
* |
- * ### Accessiblity |
+ * By default, an `<iron-form>` element validates its fields when the user presses the submit button. |
+ * To validate a form imperatively, call the form's `validate()` method, which in turn will |
+ * call `validate()` on all its children. By using `Polymer.IronValidatableBehavior`, your |
+ * custom element will get a public `validate()`, which |
+ * will return the validity of the element, and a corresponding `invalid` attribute, |
+ * which can be used for styling. |
+ * |
+ * To implement the custom validation logic of your element, you must override |
+ * the protected `_getValidity()` method of this behaviour, rather than `validate()`. |
+ * See [this](https://github.com/PolymerElements/iron-form/blob/master/demo/simple-element.html) |
+ * for an example. |
+ * |
+ * ### Accessibility |
* |
* Changing the `invalid` property, either manually or by calling `validate()` will update the |
* `aria-invalid` attribute. |
@@ -87,15 +100,35 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN |
}, |
/** |
- * @param {Object} values Passed to the validator's `validate()` function. |
- * @return {boolean} True if `values` is valid. |
+ * Returns true if the `value` is valid, and updates `invalid`. If you want |
+ * your element to have custom validation logic, do not override this method; |
+ * override `_getValidity(value)` instead. |
+ |
+ * @param {Object} value The value to be validated. By default, it is passed |
+ * to the validator's `validate()` function, if a validator is set. |
+ * @return {boolean} True if `value` is valid. |
*/ |
- validate: function(values) { |
- var valid = this._validator && this._validator.validate(values); |
- this.invalid = !valid; |
- return valid; |
- } |
+ validate: function(value) { |
+ this.invalid = !this._getValidity(value); |
+ return !this.invalid; |
+ }, |
+ /** |
+ * Returns true if `value` is valid. By default, it is passed |
+ * to the validator's `validate()` function, if a validator is set. You |
+ * should override this method if you want to implement custom validity |
+ * logic for your element. |
+ * |
+ * @param {Object} value The value to be validated. |
+ * @return {boolean} True if `value` is valid. |
+ */ |
+ |
+ _getValidity: function(value) { |
+ if (this.hasValidator()) { |
+ return this._validator.validate(value); |
+ } |
+ return true; |
+ } |
}; |
</script> |