Integrations with Zod #73
achaconm2001
started this conversation in
Ideas
Replies: 1 comment
-
Hi @achaconm2001 Something like that should work I think (not tested code) <MyField
name="field-name"
validations={[
{
rule: (value) => z.string().min(5).parse(value),
message: 'String should be longer that 5 characters',
}
]}
/> You can extract this in a custom rule (also not tested code 😉 ): const zodRule = (zod) => (value) => zod.parse(value);
<MyField
name="field-name"
validations={[
{
rule: zodRule(z.string().min(5)),
message: 'String should be longer that 5 characters',
}
]}
/> or also const zodRule = (zod) => (value) => zod.parse(value);
const ruleStringMin = (min) => zodRule(z.string().min(min));
<MyField
name="field-name"
validations={[
{
rule: ruleStringMin(5),
message: 'String should be longer that 5 characters',
}
]}
/> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi dude, I have being using formiz a lot in the last few months and I really like it. In my current job I have to integrated with an existing validation set made with zod. I was searching but I could not find any example or even idea. I don't know if you have some example of how to made that. :)
Beta Was this translation helpful? Give feedback.
All reactions