-
Notifications
You must be signed in to change notification settings - Fork 0
Description
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:
ember-bootstrap-constraint-validations/addon/components/bs-form/element.js
Lines 22 to 23 in 87068d2
// 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 setInputElement.validity.badInput
totrue
and populateInputElement.validationMessage
with an error message in that case. But they do not update thevalue
of theInputElement
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.