Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validate(dateString, dateFormat) {
const i18nCompatibleFormat = dateFormat.replace(/D/g, 'd').replace(/Y/g, 'y');
const dc = new DateConverter(i18nCompatibleFormat);
try {
const date = dc.stringToValue(dateString);
const value = !dateString.length ? null : date;
this.props.onChange(value);
} catch (err) {
this.props.onError(err.message);
}
}