Created
November 13, 2018 09:07
-
-
Save MmmarinaMarinova/469d0e2e21d9dee7dd677c44fa27077a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private _validateDate(value: any) { | |
if (this.hasFlag('notDate')) { | |
return this; | |
} | |
if (!(UtilsCollections.isString(value) || UtilsCollections.isValidNumber(value))) { | |
if (UtilsCollections.isString(this.propertyKey)) { | |
this.recordFlag('propertyNotDate', [this.value, this.propertyKey]); | |
} else { | |
this.recordFlag('notDate', [this.value]); | |
} | |
this.writeDebugLog(`${TypeValidator.name}: Date should contain some value.`); | |
return this; | |
} | |
// const dateTime = moment(value, Utils.getDateFormat(), true); | |
const dateTime: string = Utils.formatDate(value, 'en-GB'); | |
// try { | |
// dateTime = Utils.formatDate(value, 'en-GB'); | |
// } catch (e) { | |
// return undefined; | |
// } | |
if (!isDate(dateTime)) { | |
// if (dateTime.match(getLocaleDateFormat('en-GB', FormatWidth.Short))) { | |
if (UtilsCollections.isString(this.propertyKey)) { | |
this.recordFlag('propertyNotDate', [this.value, this.propertyKey]); | |
} else { | |
this.recordFlag('notDate', [this.value]); | |
} | |
} | |
this.writeDebugLog(`${TypeValidator.name}: Date cannot be parsed`); | |
// } | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment