Reputation: 28810
I know I can tell that a whole date is invalid with momentjs isValid
:
moment(values.dateOfBirth, dateFormat).isValid()
But is there a way of telling whether it is the day, month or year part which is invalid?
e.g. if the day is 30 and the month is feb then it is the day that is invalid.
Upvotes: 1
Views: 89
Reputation: 1321
You can do .invalidAt()
to determine which date value overflowed:
var m = moment("2011-10-10T10:20:90");
m.isValid(); // false
m.invalidAt(); // 5 for seconds
The integer returned has the following meaning:
source: https://momentjs.com/docs/#/parsing/is-valid/
Upvotes: 3