Skip to content
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

[Feature]: Suport set field errors programmatically #338

Open
cjoecker opened this issue Nov 15, 2023 · 5 comments
Open

[Feature]: Suport set field errors programmatically #338

cjoecker opened this issue Nov 15, 2023 · 5 comments

Comments

@cjoecker
Copy link

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

@jason-rb2
Copy link

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

@airjp73
Copy link
Owner

airjp73 commented Dec 7, 2023

This sounds reasonable to me. Would you mind opening a PR?

@cjoecker cjoecker changed the title [Feature]: Suport set fiel errors programmatically [Feature]: Suport set field errors programmatically Dec 11, 2023
@cjoecker
Copy link
Author

@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

@cjoecker
Copy link
Author

@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.

@airjp73
Copy link
Owner

airjp73 commented Mar 28, 2024

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.

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

No branches or pull requests

3 participants