Skip to content

validationMessages are not reflected in some cases #19

@jelhan

Description

@jelhan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions