Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Fields with .required() validation still end up as optional in the type #319

Open
jschuur opened this issue Jul 31, 2023 · 1 comment
Open

Comments

@jschuur
Copy link

jschuur commented Jul 31, 2023

A field like this

    defineField({
      name: "title",
      type: "string",
      title: "Title",
      validation: (Rule) => Rule.required(),
    })

still ends up with as optional in the type: title?: string;.

Is this to be expected? I see I can add codegen: { required: true }, to the `defineType object, but the that breaks that parameter's types. So now I'm doing this:

    defineField({
      name: "title",
      type: "string",
      title: "Title",
      // @ts-ignore
      codegen: { required: true },
      validation: (Rule) => Rule.required(),
    })
@jacksmethurst
Copy link

Having the same issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants