You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Binder should always validate after field's internal validation #8242
Currently Binder validates fields on ValueChangeEvent, because the valid/invalid -state is based only on the field's server-side value.
However, some fields should be also validated when the field is blurred and only the presentation value has changed. For example, when entering "asdf" to an empty DatePicker, the server-side value remains null, but the validation-state should change from valid to invalid. Same applies to eg. non-parseable numbers entered in number fields. This kind of validation should be implemented by the components themselves, but Binder should also re-validate, so that all validators are effective.
One more thing to consider is the inconsistency between Java and web component users:
The UX for web components has been designed so that "visiting" (focus and blur even without changing value) is considered "enough" to trigger validation (https://github.com/vaadin/vaadin-text-field-flow/issues/193#issuecomment-502631352).
Java forms and fields on the other hand validate only on value changes, which can mean many situations based on the ValueChangeMode, but it never means visiting a field without changing anything.
This inconsistency might become more disturbing with Vaadin 15+, where a single application may contain views written in Java, and others created with TypeScript.
Reacted by Kari Söderholm, mil3stone, Knoobie, Patrick Schmidt, ddmbest88 and Martin Vysny
To my understanding, this is only relevant in the case when a field component has a "default validator" which would always be used by Binder in addition to the user-configured validators.
Rather than reacting to every blur event, it might be more appropriate to introduce a new event that is fired by components with a default validator whenever their internal validation status changes.
I've changed the ticket title and description from "Binder should validate on blur" to be more generic, focusing on the problem and leaving the solution to be decided.
Add an event fired by HasValidator fields to notify Binder that it should validate
👍 . Having HasValidator.addValidityChangedListener() would simplify the solution at vaadin/flow-components#2176 (comment) a lot - I would be able to remove the validationChangedListener (given that there's a good way to fire those listeners).
Activity
Legioth commentedon May 11, 2020
To my understanding, this is only relevant in the case when a field component has a "default validator" which would always be used by Binder in addition to the user-configured validators.
Rather than reacting to every blur event, it might be more appropriate to introduce a new event that is fired by components with a default validator whenever their internal validation status changes.
[-]Binder: validate fields also on blur[/-][+]Binder should always validate after field's internal validation[/+]pekam commentedon Jun 1, 2020
I've changed the ticket title and description from "Binder should validate on blur" to be more generic, focusing on the problem and leaving the solution to be decided.
mvysny commentedon Apr 7, 2022
👍 . Having
HasValidator.addValidityChangedListener()would simplify the solution at vaadin/flow-components#2176 (comment) a lot - I would be able to remove thevalidationChangedListener(given that there's a good way to fire those listeners).feat: enable components to notify binder when validation state changes (
vaadin-bot commentedon Jun 27, 2022
This ticket/PR has been released with Vaadin 23.1.2.