fix when match returns null

This commit is contained in:
Pierre Noël 2022-02-15 09:52:22 +01:00
parent 82e68fca93
commit 47cd6b6290

View File

@ -120,14 +120,14 @@ const parseTime = value => {
};
const parseDate = value => {
const found = _.isString(value) ? value.match(partialDateRegex) : [];
const found = _.isString(value) ? value.match(partialDateRegex) || [] : [];
const extractedValue = found[0];
if (extractedValue && !dateRegex.test(value)) {
// TODO V5: throw an error when format yyyy-MM-dd is not respected
// throw new InvalidDateError(`Invalid format, expected yyyy-MM-dd`);
process.emitWarning(
`[deprecated] Using a date format other than yyyy-MM-dd will be deprecated. Use format yyyy-MM-dd instead. Value found: ${value}. Date kept: ${extractedValue}.`
`[deprecated] Using a date format other than YYYY-MM-DD will be removed in future versions. Date received: ${value}. Date stored: ${extractedValue}.`
);
}