Skip to content

minimum and maximum validations do not work in RJSF JSON FORM DATE PICKER COMPONENT #4517

@Yash-Kr

Description

@Yash-Kr

Prerequisites

What theme are you using?

mui

Version

5.18.3

Current Behavior

Issue : minimum and maximum validations do not work in RJSF JSON FORM DATE PICKER COMPONENT

This is an existing issue with the RJSF library itself.

  • The RJSF schema expects minimum and maximum to be number.

  • However, the html element with type = ‘date’ expects min to be a string of format ‘yyyy-mm-dd’ Check here

Case 1 : In the RJSF schema, if we pass minimum = dayjs().format(“YYYY-MM-DD”) i.e. a string. The datePicker works as expected but while submitting the form validation error is thrown

schema is invalid: data/properties/startDate/minimum must be number, data/properties/endDate/minimum must be number

Case 2 : If we try converting the minimum to number something like this dayjs().valueOf() -> then validation works fine but datePicker wont work as expected because min will be number and wont work on (Refer below screenshots)

Image
Image

Image

Expected Behavior

No response

Steps To Reproduce

JSON SCHEMA :

{
    type: "object",
    required: ["startDate"],
    properties: {
      startDate: {
        type: "string",
        title: "Start Date",
        format: "date", // Ensures only YYYY-MM-DD format
        minimum: dayjs().format("YYYY-MM-DD")
        default: dayjs().format("YYYY-MM-DD")
      },
    }
  }

Environment

- OS:
- Node:
- npm:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions