The imperative counterpart of a schema class: a plain function returning the rules.
It receives the same dependencies a class would get through its constructor, so it can reach the container's services too.
Returns what to validate, per source.
A schema instance.
export const createUserSchema = defineValidationSchema(({ i18n }) => ({ body: z.object({ email: z.string().email(i18n.t('validation.email')) })})) Copy
export const createUserSchema = defineValidationSchema(({ i18n }) => ({ body: z.object({ email: z.string().email(i18n.t('validation.email')) })}))
The imperative counterpart of a schema class: a plain function returning the rules.
It receives the same dependencies a class would get through its constructor, so it can reach the container's services too.