Dates
In this example, all sorts of date schemas are validated on the client and on the server.
const schema = z.object({
mandatory: z.date(),
optional: z.date().optional(),
nullable: z.date().nullable(),
default: z.date().default(new Date()),
})
const mutation = makeDomainFunction(schema)(async (values) => values)
export const action: ActionFunction = async ({ request }) =>
formAction({ request, schema, mutation })
export default () => <Form schema={schema} />
Dates
In this example, all sorts of date schemas are validated on the client and on the server.
const schema = z.object({
mandatory: z.date(),
optional: z.date().optional(),
nullable: z.date().nullable(),
default: z.date().default(new Date()),
})
const mutation = makeDomainFunction(schema)(async (values) => values)
export const action: ActionFunction = async ({ request }) =>
formAction({ request, schema, mutation })
export default () => <Form schema={schema} />