remix-validated-form
remix-validated-form copied to clipboard
[Feature]: Suport set field errors programmatically
What is the new or updated feature that you are suggesting?
I want to set an error on the client side without needing Zod for that.
Something like a setCustomError
function in the useFormContext
hook will be great.
I can then call it like setCustomError("myFieldName", "customError")
.
We would then need also need a resetCustomError
function.
Why should this feature be included?
I have the field A
and when it is filled, it calls an external API.
Based on the response of the API, I want to be able to set an error to another field B
using the result of the API call together with the value of the field B
I agree.
eg: check vat number
When i use fetcher.load or fetcher.submit
to validate the vat input when it loses focus(onBlur), validationError
not working because i don't submit the whole form.
So i also need one feature like setFieldError
This sounds reasonable to me. Would you mind opening a PR?
@airjp73 I will do a PR. Do you have some guidance on how to start the project? I just clone it but I'm not sure how to build the library and test the changes
@airjp73 are you still maintaining the library? I would like to open a PR but I struggled to start the project, know what is the testing approach etc.
Hi! I am but I don't have much time to work on new features. You'll likely need to add a function to the form store and access that in the useFormContext
hook. The tests are in the test-app
using Cypress -- create a route for the test and then use it in one of the existing test files (or make a new one either is fine here).
The most basic version of this feature probably only touches a couple files.
All the building, testing, etc should be doable from the root of the monrepo. But you can probably run some commands from within specific packages too.