We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description dynamic defaults always the same
MRE: Couldn't figure out how to link my specific example, but if you replace the given schema.ts with this one, you will see the id never changes
import { z } from 'zod'; import {nanoid} from 'nanoid' export const schema = z.object({ id: z.string().default(nanoid), name: z.string().min(2), email: z.string().email() });
The text was updated successfully, but these errors were encountered:
Yes, because it's only generated once, when you define it. You need to make a function that returns a new schema every time, to get a new id.
Sorry, something went wrong.
yes, it's just not what I would expect,
now I need to change the defaults on each form in load and reapply some logic in onSubmit() or something, it's cumbersome :)
It will work in strict mode, since that won't apply default values to the validated data:
const form = await superValidate(zod(schema), { strict: true })
No branches or pull requests
Description
dynamic defaults always the same
MRE:
Couldn't figure out how to link my specific example, but if you replace the given schema.ts with this one, you will see the id never changes
The text was updated successfully, but these errors were encountered: