Open TiLopes opened 1 year ago
I think that the behavior you need can be controlled by the revalidateOn
option of createForm
: https://modularforms.dev/solid/api/createForm
Using revalidateOn
and validateOn
does work. Will there ever be the possibility of overriding when to validate per field? Since not all field might require to be validated when on change.
Currently, this is not planned. In most cases, validation is so fast that optimization is not necessarily required. Feel free to go into more detail about your use case so I understand why this feature might be useful.
Let's say I have a form with two fields: name and password. While on the name the only verification that has to be done is to check if it's not empty, I may want to show the minimum requirements of the password while the user is typing and if they are fulfilled I then hide the requirements. Even without the per-field validation there are no problems but I guess it might be a bit annoying seeing the error message even though you have not finished typing everything. This is more than anything a QoL feature since like you said validation is fast enough that there would be no slowdowns.
An example with email and password:
https://github.com/fabian-hiller/modular-forms/assets/106965010/8762e540-b355-452d-b948-a311c07f2fcc
I get the error in email as soon as I type which for some might be bothersome I guess.
I understand. Technically, it should be possible to add this feature. However, I don't have the time at the moment.
Feel free to do it whenever you think is the right time. I've recently started using Solid and this library helps a lot in managing forms, keep it up!
I currently have a password field which is validated using
refine
fromzod
. But when the user first starts entering the password it is not validated and only on submit the validation starts. I knowvalidate()
exists but when I'm styling the input to show the errors I don't want the page to be loaded and the field already showing errors without the user even interacting with the field.So how could I force the validation to be run onInput?
relevant code: