Messages
The messages object
messages: { // or by html attribute 'data-message-error'
required: 'Required field',
email: 'Invalid email',
integer: 'Needs to be a integer',
digit: 'Only letters and numbers',
numeric: 'Only numbers',
pattern: 'Needs to matchs pattern',
phone: 'Invalid phone number',
url: 'Invalid url',
date: 'Invalid date',
currency: 'Invalid currency',
cep: 'Invalid cep',
maxLength: 'The amount of characters is greater than allowed',
minLength: 'The amount of characters is less than allowed',
rangeLength: 'The number of characters must be between 3 and 5',
sameLength: 'The value needs to have 5 characters',
max: 'The value needs to be less or equals to 5',
min: 'The value needs to be greater or equals to 3',
range: 'The value needs to be between 3 and 5',
equalTo: 'The value needs to be 10',
cpf: 'Invalid cpf',
cnpj: 'Invalid cnpj',
cnh: 'Invalid cnh',
creditCard: 'Invalid credit card number',
hasExtension: 'Invalid extension detected'
}
Error messages by html attribute
It's possible to set up error messages by the html attribute 'data-message-error', that will overwrite the message configured in messages object. This aproach is not good when the field has more then one validation rule.
Example:
<div>
<input type='text' class='required' data-message-error='Required field.'>
</div>
Key | Value | Description |
---|---|---|
required | string | Message error to required validation. |
string | Message error to email validation. |
|
integer | string | Message error to integer validation. |
digit | string | Message error to digit validation. |
numeric | string | Message error to numeric validation. |
pattern | string | Message error to pattern validation. |
phone | string | Message error to phone validation. |
url | string | Message error to url validation. |
date | string | Message error to date validation. |
currency | string | Message error to currency validation. |
maxLength | string | Message error to 'max length' validation. |
minLength | string | Message error to 'min length' validation. |
rangeLength | string | Message error to 'range length' validation. |
sameLength | string | Message error to 'same length' validation. |
max | string | Message error to max validation. |
min | string | Message error to min validation. |
range | string | Message error to range validation. |
equalTo | string | Message error to 'equal to' validation. |
cpf | string | Message error to cpf validation. |
cnpj | string | Message error to cnpj validation. |
cnh | string | Message error to cnh validation. |
creditCard | string | Message error to 'credit card' validation. |
hasExtension | string | Message error to 'has extension' validation. |