question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Zod validation does not show refine errors

See original GitHub issue

Hey, I started to play around with remix and enjoy using this library so far since I used Zod in my Blitz.js projects as well. Right now I have a problem that my refined validations are not shown as error.

My validator: `const password = z .string() .min(6, “Das Passwort darf maximal 6 Zeichen lang sein”) .max(100);

export const registerValidator = withZod( z .object({ email: z.string().email(), password, passwordConfirmation: password, }) .refine((data) => data.password === data.passwordConfirmation, { message: “Passwords don’t match”, path: [“passwordConfirmation”], }) );`

My Form: export const RegisterForm = () => ( <ValidatedForm validator={registerValidator} method={"post"}> <Stack spacing="6"> <TextField label={"E-Mail"} name={"email"} /> <PasswordField label={"Passwort"} name={"password"} /> <PasswordField label={"Passwort Bestätigen"} name={"passwordConfirmation"} /> <Button type="submit" colorScheme="blue" size="lg" fontSize="md"> Registrieren </Button> </Stack> </ValidatedForm> );

The normal validation for email / password and passwordConfirmation is working so far but the refined value never shows. Is there anything I am doing wrong or are these refined values not supported yet?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
engelkes-finstreetcommented, Jan 11, 2022

@airjp73 Sorry, there was an error with my zod schema. Just figured it out and it is working now!

0reactions
engelkes-finstreetcommented, Jan 6, 2022

That resolved the error 👍 I will updated the CONTRIBUTING.md with another pull request after I am done

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refine validations on object definitions don't get triggered ...
refine () function defined on the object type doesn't get triggered until the all fields in the object are defined. So, imagine you...
Read more >
typescript - wrap up zod validations for reuse
First, I would suggest keeping refinements as localized to the field they apply to as possible. For example, instead of calling refine on ......
Read more >
These docs have been translated into Chinese.
Zod is a TypeScript-first schema declaration and validation library. I'm using the term "schema" to broadly refer to any data type, from a...
Read more >
Untitled
What is Zod Zod is a TypeScript-first schema declaration and validation library. ... can't be more than 255 characters", }); ``` As you...
Read more >
Validating user input with Zod - YouTube
In this video we use Zod to validate incoming user data sent to an API route in Next.js. ... Your browser can't play...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found