From e2647d53f488aae57f373623fde460dae2776a66 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Tue, 6 Sep 2016 13:49:22 +0200 Subject: [PATCH 1/3] added message property --- iron-validator-behavior.html | 90 ++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/iron-validator-behavior.html b/iron-validator-behavior.html index d8afc84..c08a5f1 100644 --- a/iron-validator-behavior.html +++ b/iron-validator-behavior.html @@ -13,49 +13,57 @@ From 522dbe982f13e034affbbe4a0f57cfbe23c01a20 Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Tue, 6 Sep 2016 13:50:28 +0200 Subject: [PATCH 2/3] added 'for' property, allowing custom validator instances --- iron-validator-behavior.html | 11 ++++++++++- test/iron-validator-behavior.html | 13 +++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/iron-validator-behavior.html b/iron-validator-behavior.html index c08a5f1..7d5e218 100644 --- a/iron-validator-behavior.html +++ b/iron-validator-behavior.html @@ -49,12 +49,21 @@ message: { type: String, value: '' + }, + + /** + * Used to connect the custom validator instance to the desired validatable via the property `validatableId`. + */ + 'for': { + type: String, + value: '' } }, ready: function () { - new Polymer.IronMeta({type: this.validatorType, key: this.validatorName, value: this}); + var suffix = this.for ? ('--' + this.for) : ''; + new Polymer.IronMeta({type: this.validatorType, key: this.validatorName + suffix, value: this}); }, /** diff --git a/test/iron-validator-behavior.html b/test/iron-validator-behavior.html index 4acfd4f..37d5731 100644 --- a/test/iron-validator-behavior.html +++ b/test/iron-validator-behavior.html @@ -31,6 +31,12 @@ + + + + From cee6622fbd33c5431fb63c1ebc5f0fa18283cd7a Mon Sep 17 00:00:00 2001 From: Thijs Louisse Date: Wed, 7 Sep 2016 16:47:17 +0200 Subject: [PATCH 3/3] added iron-native-validator docs iron-native-validator --- bower.json | 3 + iron-native-validator.html | 112 ++++++++++++++++++++++++++++++++ iron-validator-behavior.html | 4 +- test/index.html | 4 +- test/iron-native-validator.html | 102 +++++++++++++++++++++++++++++ 5 files changed, 223 insertions(+), 2 deletions(-) create mode 100644 iron-native-validator.html create mode 100644 test/iron-native-validator.html diff --git a/bower.json b/bower.json index 48645e4..d0788b9 100644 --- a/bower.json +++ b/bower.json @@ -28,5 +28,8 @@ "test-fixture": "PolymerElements/test-fixture#^1.0.0", "web-component-tester": "^4.0.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" + }, + "resolutions": { + "iron-validatable-behavior": "feature/multipleValidators" } } diff --git a/iron-native-validator.html b/iron-native-validator.html new file mode 100644 index 0000000..a181334 --- /dev/null +++ b/iron-native-validator.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + diff --git a/iron-validator-behavior.html b/iron-validator-behavior.html index 7d5e218..8e64df4 100644 --- a/iron-validator-behavior.html +++ b/iron-validator-behavior.html @@ -69,9 +69,11 @@ /** * Implement custom validation logic in this function. * @param {Object} values The value to validate. May be any type depending on the validation logic. + * @param {HTMLElement} The element validation is being applied to. When a native validation API is present + * (like for instance on the HTMLinputElement), native validation can be used inside the validate function of the validator. * @return {Boolean} true if `values` is valid. */ - validate: function (values) { + validate: function (values, input) { } }; diff --git a/test/index.html b/test/index.html index f8a5a2e..a847bfc 100644 --- a/test/index.html +++ b/test/index.html @@ -22,7 +22,9 @@ diff --git a/test/iron-native-validator.html b/test/iron-native-validator.html new file mode 100644 index 0000000..012e833 --- /dev/null +++ b/test/iron-native-validator.html @@ -0,0 +1,102 @@ + + + + + + iron-validatable-behavior tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +