Last active
May 6, 2017 15:55
-
-
Save aaronanderson/c46f18d0ab30f1ba16f561351adb7ff7 to your computer and use it in GitHub Desktop.
match-passwords-validator.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../polymer/polymer-element.html"> | |
<link rel="import" href="../iron-validator-behavior/iron-validator-behavior.html"> | |
<script> | |
class MatchPasswordsValidator extends Polymer.mixinBehaviors([Polymer.IronValidatorBehavior], Polymer.Element) { | |
static get is() { | |
return 'match-passwords-validator'; | |
} | |
ready() { | |
super.ready(); | |
new Polymer.IronMeta({type: 'validator', key: this.validatorName, value: this}); | |
} | |
static get properties() { | |
return { | |
password: { | |
notify: true, | |
type: String | |
}, | |
validatorName: { | |
type: String, | |
value: function(){ | |
return this.is; | |
} | |
} | |
} | |
} | |
validate (values) { | |
return !values || values === this.password; | |
} | |
} | |
window.customElements.define(MatchPasswordsValidator.is, MatchPasswordsValidator); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<match-passwords-validator id="installValidator" validator-name="installValidator" password="[[install.password]]"></match-passwords-validator> | |
<paper-input id="password" label="Workspace Password" value="{{install.password}}" required minLength="6" auto-validate error-message="Enter at least 6 characters"></paper-input> | |
<paper-input id="passwordConfirm" label="Confirm" auto-validate validator="installValidator" error-message="Passwords need to match"> </paper-input> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. What's with the
new Polymer.IronMeta({type: 'validator', key: this.validatorName, value: this});
line? Is this the Polymer way for registering validators for use byIronValidatableBehavior
? It's especially curious given thatvalidatorName
has been removed in2.0-preview
branch