Created
October 23, 2019 23:14
-
-
Save guiseek/a430dd3dbb174cf51738fa3b33d9c441 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { FormErrors } from '../interfaces/form-errors.interface'; | |
export const FORM_ERRORS_CONFIG: FormErrors = { | |
required: error => `Este campo é obrigatório`, | |
email: error => `Email inválido`, | |
min: ({ min, actual }) => `O mínimo é ${min} e tem ${actual}`, | |
max: ({ max, actual }) => `O máximo é ${max} e tem ${actual}`, | |
minlength: ({ requiredLength, actualLength }) => | |
`O mínimo é ${requiredLength} e tem ${actualLength}`, | |
maxlength: ({ requiredLength, actualLength }) => | |
`O máximo é ${requiredLength} e tem ${actualLength}`, | |
pattern: ({ requiredPattern, actualValue }) => | |
`Esperado ${requiredPattern} e tem ${actualValue}`, | |
}; |
This file contains hidden or 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
import { InjectionToken } from '@angular/core'; | |
import { FORM_ERRORS_CONFIG } from './form-errors.config'; | |
export const FORM_ERRORS_CONFIG_TOKEN = 'FormErrors'; | |
export const FORM_ERRORS = new InjectionToken(FORM_ERRORS_CONFIG_TOKEN, { | |
providedIn: 'root', | |
factory: () => FORM_ERRORS_CONFIG | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment