|
| 1 | +/** |
| 2 | + * DO NOT EDIT |
| 3 | + * |
| 4 | + * This file was automatically generated by |
| 5 | + * https://github.com/Polymer/gen-typescript-declarations |
| 6 | + * |
| 7 | + * To modify these typings, edit the source file(s): |
| 8 | + * iron-validatable-behavior.html |
| 9 | + */ |
| 10 | + |
| 11 | +/// <reference path="../polymer/types/polymer.d.ts" /> |
| 12 | +/// <reference path="../iron-meta/iron-meta.d.ts" /> |
| 13 | + |
| 14 | +declare namespace Polymer { |
| 15 | + |
| 16 | + /** |
| 17 | + * `Use Polymer.IronValidatableBehavior` to implement an element that validates user input. |
| 18 | + * Use the related `Polymer.IronValidatorBehavior` to add custom validation logic to an iron-input. |
| 19 | + * |
| 20 | + * By default, an `<iron-form>` element validates its fields when the user presses the submit button. |
| 21 | + * To validate a form imperatively, call the form's `validate()` method, which in turn will |
| 22 | + * call `validate()` on all its children. By using `Polymer.IronValidatableBehavior`, your |
| 23 | + * custom element will get a public `validate()`, which |
| 24 | + * will return the validity of the element, and a corresponding `invalid` attribute, |
| 25 | + * which can be used for styling. |
| 26 | + * |
| 27 | + * To implement the custom validation logic of your element, you must override |
| 28 | + * the protected `_getValidity()` method of this behaviour, rather than `validate()`. |
| 29 | + * See [this](https://github.com/PolymerElements/iron-form/blob/master/demo/simple-element.html) |
| 30 | + * for an example. |
| 31 | + * |
| 32 | + * ### Accessibility |
| 33 | + * |
| 34 | + * Changing the `invalid` property, either manually or by calling `validate()` will update the |
| 35 | + * `aria-invalid` attribute. |
| 36 | + */ |
| 37 | + interface IronValidatableBehavior { |
| 38 | + |
| 39 | + /** |
| 40 | + * Name of the validator to use. |
| 41 | + */ |
| 42 | + validator: string|null|undefined; |
| 43 | + |
| 44 | + /** |
| 45 | + * True if the last call to `validate` is invalid. |
| 46 | + */ |
| 47 | + invalid: boolean|null|undefined; |
| 48 | + |
| 49 | + /** |
| 50 | + * Recompute this every time it's needed, because we don't know if the |
| 51 | + * underlying IronValidatableBehaviorMeta has changed. |
| 52 | + */ |
| 53 | + readonly _validator: any; |
| 54 | + registered(): void; |
| 55 | + _invalidChanged(): void; |
| 56 | + |
| 57 | + /** |
| 58 | + * @returns True if the validator `validator` exists. |
| 59 | + */ |
| 60 | + hasValidator(): boolean; |
| 61 | + |
| 62 | + /** |
| 63 | + * Returns true if the `value` is valid, and updates `invalid`. If you want |
| 64 | + * your element to have custom validation logic, do not override this method; |
| 65 | + * override `_getValidity(value)` instead. |
| 66 | + * |
| 67 | + * @param value Deprecated: The value to be validated. By default, |
| 68 | + * it is passed to the validator's `validate()` function, if a validator is set. |
| 69 | + * If this argument is not specified, then the element's `value` property |
| 70 | + * is used, if it exists. |
| 71 | + * @returns True if `value` is valid. |
| 72 | + */ |
| 73 | + validate(value: object|null): boolean; |
| 74 | + _getValidity(value: any): any; |
| 75 | + } |
| 76 | + |
| 77 | + const IronValidatableBehavior: object; |
| 78 | +} |
0 commit comments