Created
March 26, 2019 10:44
-
-
Save dancornilov/0dab77269d68519606f40c92bcf5f624 to your computer and use it in GitHub Desktop.
Generate validator message
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
/** | |
* Check if the validator has a custom validation message | |
* | |
* @param errors | |
* | |
* @return string | |
*/ | |
public message(errors: ValidationErrors | null): string { | |
const properties = Object.keys(errors); | |
let customMessage: boolean; | |
if (this.customValidation) { | |
customMessage = (properties.indexOf(this.customValidation.name) > -1); | |
} | |
return customMessage ? this.customValidation.text : `validators.${properties[0]}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment