I need to validate a date string for the format dd/mm/yyyy
with a regular expresssion.
This regex validates dd/mm/yyyy
, but not the invalid
The best way according to me is to use the Moment.js isValid() method by specifying the format and use strict parsing.
As moment.js documentation says
As of version 2.3.0, you may specify a boolean for the last argument to make Moment use strict parsing. Strict parsing requires that the format and input match exactly, including delimiters.
value = '2020-05-25';
format = 'YYYY-MM-DD';
moment(value, format, true).isValid() // true