| OLD | NEW |
| (Empty) | |
| 1 <!-- |
| 2 @license |
| 3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved. |
| 4 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
| 6 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
| 7 Code distributed by Google as part of the polymer project is also |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <link rel="import" href="../polymer/polymer.html"> |
| 12 <link rel="import" href="../iron-meta/iron-meta.html"> |
| 13 |
| 14 <script> |
| 15 |
| 16 /** |
| 17 * Use `Polymer.IronValidatorBehavior` to implement a custom input/form valida
tor. Element |
| 18 * instances implementing this behavior will be registered for use in elements
that implement |
| 19 * `Polymer.IronValidatableBehavior`. |
| 20 * |
| 21 * @demo demo/index.html |
| 22 * @polymerBehavior |
| 23 */ |
| 24 Polymer.IronValidatorBehavior = { |
| 25 |
| 26 properties: { |
| 27 |
| 28 /** |
| 29 * Namespace for this validator. |
| 30 */ |
| 31 validatorType: { |
| 32 type: String, |
| 33 value: 'validator' |
| 34 }, |
| 35 |
| 36 /** |
| 37 * Name for this validator, used by `Polymer.IronValidatableBehavior` to l
ookup this element. |
| 38 */ |
| 39 validatorName: { |
| 40 type: String, |
| 41 value: function() { |
| 42 return this.is; |
| 43 } |
| 44 } |
| 45 |
| 46 }, |
| 47 |
| 48 ready: function() { |
| 49 new Polymer.IronMeta({type: this.validatorType, key: this.validatorName, v
alue: this}); |
| 50 }, |
| 51 |
| 52 /** |
| 53 * Implement custom validation logic in this function. |
| 54 * @param {Object} values The value to validate. May be any type depending o
n the validation logic. |
| 55 * @return {Boolean} true if `values` is valid. |
| 56 */ |
| 57 validate: function(values) { |
| 58 } |
| 59 }; |
| 60 |
| 61 </script> |
| OLD | NEW |