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

validationMessages are not reflected in some cases #19

Open
jelhan opened this issue Oct 1, 2023 · 0 comments
Open

validationMessages are not reflected in some cases #19

jelhan opened this issue Oct 1, 2023 · 0 comments

Comments

@jelhan
Copy link

jelhan commented Oct 1, 2023

For integrating Element.validationMessage with Ember's autotracking system, the addon builds on the assumption that whenever validationMessage of an element changes, also the value property of FormElement changes:

// native validation state doesn't integrate with Ember's autotracking, so we need to invalidate our `errors` getter explicitly when
// `this.value` changes by consuming it here.

This assumption is not correct in some cases:

  • <input type="time"> might be partially filled. Browser set InputElement.validity.badInput to true and populate InputElement.validationMessage with an error message in that case. But they do not update the value of the InputElement as it must not be a bad input.
  • Consumers may set a custom validation message, which depends on the current locale. The current locale may change and therefore the validation message without the value being changed.

For the second case a consumer may fork this repository and consume current locale in addition to the value in errors getter. But I don't see a solution for the first case. As far as I know there isn't any event fired from the browser when an user partially fills the text input.

I run into this limitation when doing a PoC on migrating an use case from ember-cp-validations to native validations of the platform using this addon. My use case required both: showing validation errors when input is partially filled and updating validation errors when the locale changes. The PoC showing the two problems could be found here: https://github.com/jelhan/ember-bootstrap-constraint-validations-intl-support-poc

I also asked at StackOverflow about this limitation of constraint validation API and if there is a way around it.

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

No branches or pull requests

1 participant