Last active
June 14, 2017 06:17
-
-
Save Takas0522/6e94863a526afe69da85a133612f32b8 to your computer and use it in GitHub Desktop.
validationmessage.ts-Angularv4ReactiveFormのやつ
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
const REQUIRED_MESSAGE = '@1@は必須項目です。'; | |
const MAXLENGTH_MESSAGE = '@1@は@2@文字以内で入力して下さい。'; | |
export class ValidarionMessages { | |
static getRequredMessage(field: string): string { | |
return REQUIRED_MESSAGE.replace(/@1@/g, field); | |
} | |
static getMaxLengthMessage(field: string, maxlength: number): string { | |
let retMessage = MAXLENGTH_MESSAGE.replace(/@1@/g, field); | |
retMessage = retMessage.replace(/@2@/, maxlength.toString()); | |
return retMessage; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment