Skip to content
This repository was archived by the owner on May 6, 2023. It is now read-only.

Possible to pick/omit? #210

Description

@Kolby-Udacity

Hi, I'm trying to utilize my existing sanity-typed-schema-builder document to create a new Zod document. I want to pick fields from the former to add to the latter. Is this possible somehow?

Example:

export const programSanitySchema = s.document({
  name: 'program',
  title: 'Program',
  fields: [
    {
      name: 'title',
      title: 'Title',
      description: 'The title of the program',
      type: s.string(),
    },
    {
      name: 'description',
      title: 'Description',
      description: 'The description of the program',
      type: s.string(),
    }
  ],
});

export const programPreviewZodSchema = z.object({
  title: programSanitySchema.pick({title: true})
});

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions