1const date = '2016-10-19';
2const dateFormat = 'DD-MM-YYYY';
3const toDateFormat = moment(new Date(date)).format(dateFormat);
4moment(toDateFormat, dateFormat, true).isValid();
5
6// Note: `new Date()` circumvents the warning that
7// Moment throws (https://momentjs.com/guides/#/warnings/js-date/),
8// but may not be optimal.