-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Adding onBlur
event next to onChange
event
#504
Comments
I'm hesitant to add events not related to the submit process, as they are quite error-prone. If you check the API for the |
@ciscoheat Please show me an example based on the docs, how would you set the error messages for fields in a form with multiple inputs, using the I've tried this as an example:
It behaves almost perfectly, except the fact that If something doesn't quite add up, what I need it to add custom message for custom validations using |
Combining the |
Yeah, I thought about that.. using both the custom validation and the validators might create confusion behind the scenes. The issue simply comes from the fact that the blur event happens before I will give it a try with the tick tho :) |
You could try setting the validationMethod to 'onsubmit' and see if that helps. Maybe an extra option to turn it off is the solution. |
Alright, apparently it works with |
@ciscoheat |
I've written some about it here: https://discord.com/channels/1088090866649939990/1088090867723669616/1206540174381817936 |
Is your feature request related to a problem? Please describe.
In the previous version I was using
validators
property ofsuperForm()
to add some custom validations for multiple fields where I was setting the errors usingi18n
.Now I can't do that anymore on
onblur
, but only withinonChange
event, which is not an option.Basically I need to add custom field validations outside the adapters and I cannot mix the
i18n
withzod
or any other adapter because I cannot use localized string when I create the schema to validate the fields on blur, as it should normally work.I dont want to use the deprecated
superformClient
.Describe the solution you'd like
I would need an
onBlur
event to have the same destructed event likeonChange
(or something similar), so I can create custom validations for each field, butonblur
.In the previous version,
validators
supported adding separate error messages for the fields and I need to keep that.Describe alternatives you've considered
I have tried using the
validationMethod: 'onblur'
andvalidators: zod(createProjectSchema)
which works perfectly, but as I said above, I cannot set localized strings in my schema (using therefine
method) because I have a more complex logic for validating the fields, where the adapter is not enough.I checked all the documentation and examples, but I couldn't find such a case where you add custom validations for fields, outside the adapters.
The text was updated successfully, but these errors were encountered: