-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow manual validation #26
Conversation
b962a6d
to
5ddeff9
Compare
* Validates the input element and sets an error style if needed. | ||
*/ | ||
validate:function () { | ||
return this.querySelector('paper-input-container').validate(this.inputElement, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a little weird to me to have a validate
function on <paper-input-container>
, since it doesn't have validatable content but reflects the state of a validatable thing in its light DOM.
What do you think about calling validate
on the input, which sets invalid
(the property needs a notify:true
in iron-validatable-behavior
), and use binding to set the invalid
property on the <paper-input-container>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or fire an event from iron-validatable-behavior
that the container listens for to set invalid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
5ddeff9
to
a72e7bb
Compare
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
a72e7bb
to
bf99fcf
Compare
bf99fcf
to
035781e
Compare
CLAs look good, thanks! |
} else if (inputElement.checkValidity) { | ||
valid = inputElement.checkValidity(); | ||
|
||
// type="number" doesn't have a validate method... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only iron-input
's have a validate
method actually.
4fc69d6
to
96f42b6
Compare
ping? |
Sorry, lgtm. |
96f42b6
to
c4138f9
Compare
So if one calls .setCustomValidity('Test error') on the underlying input (is="iron-input") as per original 0.5 doc - should it automatically trigger paper-input's invalid state and display the error message? Doesn't seem to be the case. var pi = document.getElementById('test'); var i = Polymer.dom(pi.root).querySelector('input'); i.setCustomValidity('Test error'); |
Added a
validate()
function to the behaviour, and refactored thepaper-input-container
to get notified (and care) when the containediron-input
's validity changes. PTAL.Needs PolymerElements/iron-input#13 to work.