Skip to content

Bug - [DatePicker] - [validator function converts date automatically and exports a new date when users input some special wrong date ] #1269

Open
@judy20191103

Description

@judy20191103

Describe the problem
PatternFly DatePicker component has converted 2023-06-31 into 2023-07-01 for us, which triggered our weekend validation.
Actually, I want to get the true value 2023-06-31, I know its an invalid date, but it's true, it makes sure our logic depends on the users input value.

How do you reproduce the problem?
I show a sample demo like below:

<DatePicker validators={[rangeValidator]} />

function rangeValidator(date: Date) {
const dayOfWeek = new Date(date).getDay();
const isWeekend = dayOfWeek === 6 || dayOfWeek === 0
console.log("date==", date);// 2023-07-01, 2022-10-01, 2023-05-01
if (isWeekend) {
return "Date falls on weekend.";
}
return "";
}

I have tried other cases like 2022-09-31 => 2022-10-01, 2023-04-31 => 2023-05-01, the DatePicker component converts these dates automatically and exports the later value, resulting in a validation notice.

Expected behavior
I want to get the true value the users input, like 2023-06-31

Is this issue blocking you?
Not yet

Screenshots
If applicable, add screenshots to help explain the issue.

What is your environment?

  • OS: [e.g. iOS] Mac
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] "@patternfly/react-core": "^4.221.3",

What is your product and what release date are you targeting?

Any other information?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions