Skip to content

yup.date().nullable() field does not result in nullable date prop in the JSON schemaΒ #19

@stijnjanmaat

Description

@stijnjanmaat

A schema like this:

const yupSchema = yup.object().shape({
  someDate: yup.date().nullable(),
  someString: yup.string().nullable(),
});

...results in a json schema like this:

{
  "type": "object",
  "default": {},
  "properties": {
    "someDate": {
      "type": "string",
      "format": "date-time"
    },
    "someString": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}

I expect it to respect the nullable method on date(). So should result in:

{
  "type": "object",
  "default": {},
  "properties": {
    "someDate": {
      "type": [
        "string", 
        "null",
      ],
      "format": "date-time"
    },
    "someString": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}

Could you add support for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions