Comments (9)
Hi @Smona 👋🏻
FIY Yup sync validation added in the v2.0.0-beta.5
You can try it by installing yarn add @hookform/[email protected]
from resolvers.
@jorisre hey, awesome! Thanks for taking this on
from resolvers.
@GollyJer v6 will not return defaultValue from watch
, unless supplied as default values
watch(undefined, defualtValues)
we are fixing this behaviour for V7, so defaultValue will be returned before render.
from resolvers.
resolver: async (data) => schema.validateSync(data)
have you tried to build your own?
from resolvers.
No, not yet. I could, but then I would have to copy-paste the source code for the error parser and other imports of the resolver. Which kind of defeats the purpose of the repo 😅
I'd be happy to submit a PR here if you approve of the idea!
from resolvers.
I suppose I'm assuming that useForm
would support a synchronous validation resolver. If that's not the case, I can see why this would be harder to implement.
from resolvers.
HI @jorisre 👋
Stumbled on this today looking for a synchronous solution.
I have
"@hookform/resolvers": "2.0.0-beta.5",
"react-hook-form": "^6.14.2",
And the following code.
const { control, errors, watch, formState } = useForm<FormInputs>({
mode: 'onChange',
reValidateMode: 'onChange',
defaultValues,
resolver: yupResolver(
Yup.object().shape({
syringeUnits: Yup.number().required().moreThan(0),
syringeTickMarks: Yup.number().required().moreThan(0),
powderMilligrams: Yup.number().required().moreThan(0),
waterMilliliters: Yup.number().required().moreThan(0),
desiredDoseAmount: Yup.number().required().moreThan(0),
}),
undefined,
{ mode: 'sync' }
),
});
const formValues = watch();
console.log(formValues);
I'm still seeing formValues print the old and new value when typing in a field.
Am I doing something wrong?
Thanks for the work on this! It's going to be super helpful.
from resolvers.
@bluebill1049 Good to know. Thanks!
from resolvers.
Closing, V2 released 🎉
from resolvers.
Related Issues (20)
- Valibot - Optional not found
- issue: Valibot resolver optional not Found HOT 1
- 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
- [Zod]: Resolver does not validate to reflect correct error state without manual form.trigger() HOT 8
- zodResolver / superRefine / useFieldArray: useForm errors are not updated to reflect zodResolver errors 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.