Skip to content
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

Merged
merged 1 commit into from
May 18, 2015
Merged

allow manual validation #26

merged 1 commit into from
May 18, 2015

Conversation

notwaldorf
Copy link
Contributor

Added a validate() function to the behaviour, and refactored the paper-input-container to get notified (and care) when the contained iron-input's validity changes. PTAL.

Needs PolymerElements/iron-input#13 to work.

* Validates the input element and sets an error style if needed.
*/
validate:function () {
return this.querySelector('paper-input-container').validate(this.inputElement, true);
Copy link
Contributor

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>?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot
Copy link

CLAs look good, thanks!

} else if (inputElement.checkValidity) {
valid = inputElement.checkValidity();

// type="number" doesn't have a validate method...
Copy link
Contributor

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.

@notwaldorf notwaldorf force-pushed the on-demand-validation branch 2 times, most recently from 4fc69d6 to 96f42b6 Compare May 13, 2015 18:38
@notwaldorf
Copy link
Contributor Author

ping?

@morethanreal
Copy link
Contributor

Sorry, lgtm.

notwaldorf added a commit that referenced this pull request May 18, 2015
@notwaldorf notwaldorf merged commit b34c14a into master May 18, 2015
@notwaldorf notwaldorf deleted the on-demand-validation branch May 18, 2015 18:48
@govis
Copy link

govis commented May 26, 2015

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');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants