#props.validate is not a function

24 messages · Page 1 of 1 (latest)

jolly walrus
#

Hi guys! I'm out of my wits trying find a solution for this error.

And I'm using version:
"@tanstack/react-form": "^1.14.1",
"zod": "^3.25.16",

I'm trying to use zod for validation but whenever I try to input I get this props.validate as an error:

#
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>
    );
}

urban sinew
#

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?

jolly walrus
#

Thanks @urban sinew yup I've re-installed the packages as I was trailing a similar issue that you commented also haha

urban sinew
#

well, thanks to retrying this, i learned that zod v4 is officially out! So that‘s great news too

jolly walrus
#

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.

urban sinew
jolly walrus
#

yup I'm using pnpm, I wonder what command they use

urban sinew
#

they didn't specify. Just said to 'clear the cache'

jolly walrus
#

fingers crossed, re installing again haha

#

still the same, I still get the error :((

urban sinew
#

did you simply prune the cache or delete it completely?

jolly walrus
#

I pruned it

jolly walrus
#

This only happens when I have a validate function

urban sinew
jolly walrus
#

it's undefined

#

uhhh I think I might have found the culprit @urban sinew

urban sinew
#

well there you have it

#

your zod is not standard schema

jolly walrus
#

I don't know why but because of how my pnpm workspace was set zod versions were mismatched this might have cause an issue because of how pnpm packages work?

#

but yeah thank you!