Comments (8)
We're having a similar issue, described in a comment here! I think that these two issues are dupes.
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgscInteresting, could you point me to some docs for this? would like to dig a lil deeper
I found it by accident. I was looking for something like "dependencies" because I worked with Ant Design for a very long time and there I used it a lot to solve this kind of problem. Once I found this in the rules object, I set it up, tested it and it actually works, but why isn't there anything about it in the documentation? Maybe it also works by accident :D
yeah the docs seem pretty arcane atp, i wonder if it uses trigger() under the hood, since the validations were working fine with updates to formstates as well but re-renders were not being "triggered"
Maybe, but I do not think so. The problem with using trigger() is that in the case of mode="onSubmit" (default) the error will be displayed even before the form is submitted but using rules.deps, the error appears only after submit.
yeah we're using submitCount
from formState to only trigger() when the form is submitted once.
since the entire schema needs to be validated all trigger() calls we're already running in a useEffect using watch()
's subscription. just added that check in useEffect
here's the snippet for that
useEffect(() => {
if (form.formState.submitCount === 0) {
return;
}
const subscription = form.watch(() => form.trigger());
return () => subscription.unsubscribe();
}, [form.watch, form.trigger, form.formState, form]);
from resolvers.
I have a similar issue. The refine function is triggered and resolved but error from formState.erros does not disappear -> if I call form.trigger() in every onChange field callback then everything works good and errors are cleared form formState.
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgsc
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgsc
Interesting,
could you point me to some docs for this? would like to dig a lil deeper
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgscInteresting, could you point me to some docs for this? would like to dig a lil deeper
I found it by accident. I was looking for something like "dependencies" because I worked with Ant Design for a very long time and there I used it a lot to solve this kind of problem. Once I found this in the rules object, I set it up, tested it and it actually works, but why isn't there anything about it in the documentation? Maybe it also works by accident :D
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgscInteresting, could you point me to some docs for this? would like to dig a lil deeper
I found it by accident. I was looking for something like "dependencies" because I worked with Ant Design for a very long time and there I used it a lot to solve this kind of problem. Once I found this in the rules object, I set it up, tested it and it actually works, but why isn't there anything about it in the documentation? Maybe it also works by accident :D
yeah the docs seem pretty arcane atp, i wonder if it uses trigger() under the hood, since the validations were working fine with updates to formstates as well but re-renders were not being "triggered"
from resolvers.
@MusaGillani the interesting thing is that when you add rules={{ deps: ['field1', 'field2'] }} to FormField (which passthrough to Controller) it works as expected :D
https://stackblitz.com/edit/stackblitz-starters-8cqgscInteresting, could you point me to some docs for this? would like to dig a lil deeper
I found it by accident. I was looking for something like "dependencies" because I worked with Ant Design for a very long time and there I used it a lot to solve this kind of problem. Once I found this in the rules object, I set it up, tested it and it actually works, but why isn't there anything about it in the documentation? Maybe it also works by accident :D
yeah the docs seem pretty arcane atp, i wonder if it uses trigger() under the hood, since the validations were working fine with updates to formstates as well but re-renders were not being "triggered"
Maybe, but I do not think so. The problem with using trigger() is that in the case of mode="onSubmit" (default) the error will be displayed even before the form is submitted but using rules.deps, the error appears only after submit.
from resolvers.
Related Issues (20)
- AJV Resolver - When ajv schema contains `default` for certain properties, `getValues()` returns the form data with properties overwritten
- typescript type error for yupResolver HOT 22
- Not Possible to use Zod omit on schema passed to resolver HOT 1
- Zod continues to throw errors while using async refinements with react hook form when zod resolver mode is set to async HOT 2
- Issue with valibotResolver causing unexpected form submission behavior HOT 3
- typescript problem in AJV resolver HOT 1
- Fields configured as mandatory are not being validated and are ignored.
- errors object creating circular structure with yup resolver
- Zod superRefine does not correctly revalidate the form on change HOT 2
- Issue with Resolvers tranform
- Extend typeboxResolver with additional types; getting "Unknown type" in Visit3
- AJV resolver is async mode is not working
- Support `@effect/schema` HOT 4
- when type of input is radio,valueAsNumber dont work anymore HOT 1
- `Joi` resolver crashes on `File` validation
- When using `classValidatorResolver`, combining `@IsOptional()` with `@Length()` makes the field required
- zodResolver / superRefine / useFieldArray: useForm errors are not updated to reflect zodResolver errors HOT 1
- Zodresolver `getFieldState(..).error` type is incorrect HOT 1
- Typeerror when used with zod 3.23 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from resolvers.