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.

Validation .isValid() doesn't work always

See original GitHub issue

The .isValid() validation doesn’t function correctly under the following condition:

  • When the the day part is 31 for a month which didn’t have 31 days.

Some instances where .isValid() returns true for a date that is invalid:

  • dayjs().isValid('1995-02-31')
  • dayjs().isValid('1995-03-31')
  • dayjs().isValid('1995-04-31')
  • dayjs().isValid('1995-06-31')
  • dayjs().isValid('1995-09-31')
  • dayjs().isValid('1995-11-31')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

44reactions
huberzeljkocommented, Oct 3, 2019

Is this an option to validate if date exist?

function validate(date, format) {
  return dayjs(date, format).format(format) === date;
}

validate('2019/02/31', 'YYYY/MM/DD') // false
18reactions
wmoneckecommented, Jun 5, 2021

Why is this still closed? This issue cost me at least 4 hours because it is still broken.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'isValid' is always false - Stack Overflow
I don't want validation only on submit, and I explicitly stated that using the configuration, or at least that is how I understand...
Read more >
Part 9, add validation to an ASP.NET Core MVC app
Run the app and navigate to the Movies controller. Select the Create New link to add a new movie. Fill out the form...
Read more >
Client-side form validation - Learn web development | MDN
So why do we insist on validating our forms? There are three main reasons: We want to get the right data, in the...
Read more >
Hibernate Validator 8.0.0.Final - Jakarta Bean Validation ...
As constraints, object graph validation also works for container elements ... unique identifier according to RFC 4122. null is always valid.
Read more >
validate.js
The validator will not be run if the options are falsy. Important! Most validators consider undefined values ( null and undefined ) valid...
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