Skip to content

Instantly share code, notes, and snippets.

@Takas0522
Last active June 14, 2017 06:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Takas0522/6e94863a526afe69da85a133612f32b8 to your computer and use it in GitHub Desktop.
Save Takas0522/6e94863a526afe69da85a133612f32b8 to your computer and use it in GitHub Desktop.
validationmessage.ts-Angularv4ReactiveFormのやつ
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