isDate()
See original GitHub issueHi,
I hope somebody can help me figure out what I’m doing wrong:
req.checkBody('profile.dateOfBirth', 'Date of birth needs to be a valid date').isDate({format: 'DD-MM-YYYY'});
Yields the following validation error:
{
"param": "profile.dateOfBirth",
"msg": "Date of birth needs to be a valid date",
"value": "22-06-1977"
}
I tried with different format strings, no format string, etc but the result is always the same. All other validations (notEmpty, isAlpha, len, etc) on other params work as expected only isDate consistently fails.
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
SQL Server ISDATE() Function - W3Schools
The ISDATE() function checks an expression and returns 1 if it is a valid date, otherwise 0. Syntax. ISDATE(expression). Parameter Values ...
Read more >ISDATE (Transact-SQL) - SQL Server - Microsoft Learn
In this article ... Returns 1 if the expression is a valid datetime value; otherwise, 0. ISDATE returns 0 if the expression is...
Read more >SQL Server ISDATE() Function By Practical Examples
The ISDATE() function accepts an argument and returns 1 if that argument is a valid DATE , TIME , or DATETIME value; otherwise,...
Read more >SQL ISDATE Function Use and Examples
The ISDATE function returns 1 if the parameter value is a valid date and 0 if it is not a valid date. Syntax....
Read more >ISDATE() Function in SQL Server - GeeksforGeeks
ISDATE() Function in SQL Server · This function is used to find if the stated date is valid or not. · This function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @afrikhero @Pedro-Sousa-da-Rocha,
isISO8601
is probably the best method from validator to validate dates.express-validator is simply a middleware wrapper of validator.js, so all available validators are listed on their README. Just looking at their docs/code, the
isDate
method does not accept an object for specifying a format. Behind the scenes, this is how it is validated:So in order for
isDate
to work, you will either need to:isValid()
.Let me know if this works. If so, please close the issue.