Skip to content

(refactor) Validation onChange & onBlur only for field, and onSubmit for form #955

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

Merged
merged 2 commits into from
Jun 26, 2025

Conversation

carere
Copy link
Contributor

@carere carere commented Jun 24, 2025

This PR remove the globals validators from all the Form in the app (except for the onSubmit).
The removed validators are now assigned to each form's field.

@carere carere self-assigned this Jun 24, 2025
@carere carere marked this pull request as ready for review June 26, 2025 09:39
@carere carere force-pushed the fix/onblur-bug-untouched-form branch from 1692e10 to 6a507cb Compare June 26, 2025 09:39
@carere carere requested a review from a team June 26, 2025 10:16
@carere carere merged commit aee7a75 into main Jun 26, 2025
4 checks passed
@carere carere deleted the fix/onblur-bug-untouched-form branch June 26, 2025 10:26
@Pascal-Delange
Copy link
Contributor

I'm arriving after the merge but naively this looks pretty verbose - is there any more "shorthand" way of handling this ?

@ChibiBlasphem
Copy link
Contributor

Is there a reason why all the validators have been moving to field level? I can't understand why we would want to have so much boilerplate per field.
When I tested it, just removing the onBlur form validation was working (if you have an onChange validation the onBlur is pretty much useless)

@carere
Copy link
Contributor Author

carere commented Jun 27, 2025

@ChibiBlasphem the problem is that when you specify validators on the form, they validate ALL the form, if ANY fields "change" or "blur".
By specifying those validators on field level, you prevent one field "onChange" to trigger the form "onChange", and then validate the all form :)

@ChibiBlasphem
Copy link
Contributor

@ChibiBlasphem the problem is that when you specify validators on the form, they validate ALL the form, if ANY fields "change" or "blur". By specifying those validators on field level, you prevent one field "onChange" to trigger the form "onChange", and then validate the all form :)

Ok I get it. It's a little verbose so I think we will eventually create an abstraction to manage this more nicely.

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.

4 participants