question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DatePicker: Validation error "INVALID_RANGE_DATES_SEQUENTIAL" when dates are the same

See original GitHub issue

Describe the bug

If you have a datepicker using selectionMode=“range” and select the same date for the starting date and end date, you get an error saying that the start date is greater than the end date, which is incorrect. I tracked down the issue to this line: https://github.com/primefaces/primefaces/blob/master/primefaces/src/main/java/org/primefaces/component/datepicker/DatePicker.java#L178

I changed it in my local copy of primefaces from:

 if (isValid() && startDate.compareTo(endDate) > -1) {
         setValid(false);
         validationResult = ValidationResult.INVALID_RANGE_DATES_SEQUENTIAL;
 }

to:

 if (isValid() && startDate.compareTo(endDate) > 0) {
         setValid(false);
         validationResult = ValidationResult.INVALID_RANGE_DATES_SEQUENTIAL;
 }

Which fixed the issue

Reproducer

No response

Expected behavior

No validation error should occur when the dates are the same.

PrimeFaces edition

Community

PrimeFaces version

12.0.0-RC3

Theme

No response

JSF implementation

All

JSF version

Any

Java version

Any

Browser(s)

Any

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Sep 22, 2022

PR Submitted letting the integration tests run now

0reactions
newk5commented, Sep 23, 2022

Also as I said above I chose the same exact month for both the start and end date so those values there on the debugger are correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Material Datepicker validation error #23097 - GitHub
It seems like it only checks the same date that caused the error, rather than checking both dates for an update in the...
Read more >
Angular 5, Angular Material: Datepicker validation not working
I use ErrorStateMatcher in my Angular Material Forms, it works perfectly. You should have a code that looks like that:
Read more >
DatePicker.DateValidationError Event - Microsoft Learn
The following example creates a DatePicker that displays the dates in August 2009 and specifies that each Saturday and Sunday is not selectable....
Read more >
Date Picker Plugin Causes field validation errors
Has anyone else noticed that using the Datepicker plugin causes the form not to send because of “validation issues” even without any required...
Read more >
DatePicker - Mantine
Capture date or dates range from user. ... DateRangePicker component (supports the same props as DatePicker ... Error as boolean – red border...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found