Skip to content

Commit bd11101

Browse files
committed
Merge pull request jquense#323 from evax/moment-localizer-parse-fix
Handle invalid dates in the moment localizer
2 parents c664145 + c6bbb03 commit bd11101

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/localizers/moment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export default function(moment) {
5151
},
5252

5353
parse(value, format, culture) {
54-
return value ? getMoment(culture, value, format).toDate() : null
54+
if (!value) return null;
55+
const m = getMoment(culture, value, format);
56+
if (m.isValid()) return m.toDate();
57+
return null;
5558
},
5659

5760
format(value, format, culture) {

0 commit comments

Comments
 (0)