TanStackT
TanStack9mo ago
5 replies
good-rose

Different schema for form and output

Is there a way to specify two different schemas, one for the form state and one for the output upon submission?

For example the form schema would be:
// type or using zod
type FormSchema = {
  name: string;
  timezone: Timezone | null; // populated via select
}


while the output schema would be:

type OutputSchema = {
  name: string;
  timezone: Timezone; // notice that this must be set once the form is submitted
}


FormSchema would be used within the form (e.g. showing a preview of what the timezone settings are when a timezone is selected or not) while OutputSchema would only be used upon submission and validation.
Was this page helpful?