Is there a way in momentjs
to strictly parse input while accepting wildcards?
To strictly parse input, pass true
as the third parameter.
I want to support date formats like DD/MM/YYYY
, DD-MM-YYYY
, DD.MM.YYYY
, and DD MM YYYY
. Instead of maintaining a list with all possible delimiters, I would like to use wildcards such as *
or .
. Is it feasible to enforce the date format while disregarding the delimiter?
moment('12/12/2012', ["DD/MM/YYYY", "DD-MM-YYYY", "DD.MM.YYYY", "DD MM YYYY"], true).isValid() === true;
// Ideally ignoring delimiter type, this should evaluate to false
moment('12/12/2012', "DD*MM*YYYY", true).isValid() === false;