#props.validate is not a function
24 messages · Page 1 of 1 (latest)
const testSchema = z.object({
name: z
.string()
.min(3, "Must be at least 3 characters")
.max(50, "Cannot exceed 50 characters"),
});
function RouteComponent() {
const form = useForm({
defaultValues: {
name: "",
},
validators: {
onChange: testSchema,
},
onSubmit: (values) => {
console.log(values);
},
});
return (
<div>
<form
onSubmit={(e) => {
e.preventDefault();
e.stopPropagation();
form.handleSubmit();
}}
>
<form.Field
name="name"
children={(field) => (
<div>
<div>
<Label htmlFor="name">Name</Label>
<Input
id={field.name}
name={field.name}
value={field.state.value}
onChange={(e) => field.handleChange(e.target.value)}
/>
</div>
<FieldError field={field} />
</div>
)}
/>
<button type="submit">Submit</button>
</form>
</div>
);
}
I should read the version before spitting guesses. Sorry about that 😅
anyways, validate should definitely be there for standard schemas, and your zod version is high enough for that. Does clearing node_modules and reinstalling packages work?
https://stackblitz.com/edit/vitejs-vite-n5vvckrv?file=package.json @jolly walrus appears to work on a freshly installed stackblitz with zod v3.25.16
Thanks @urban sinew yup I've re-installed the packages as I was trailing a similar issue that you commented also haha
well, thanks to retrying this, i learned that zod v4 is officially out! So that‘s great news too
I'll create a fresh project and see if it still happens tho but It's unfortunate I've done re-installation like 2 times. I wonder what might be the cause for this.
do you use pnpm perhaps? I heard from a user earlier today that they had to clear cache first
yup I'm using pnpm, I wonder what command they use
fingers crossed, re installing again haha
still the same, I still get the error :((
did you simply prune the cache or delete it completely?
I pruned it
This only happens when I have a validate function
can you try calling yourZodSchema['~validate']?