Creates an alias between a single attribute's validations to another. This copies all messages, errors, etc., to the current attribute as well as its validation state (isValid, isValidating, etc.)
Examples
validator('alias', 'attribute')
validator('alias', {
alias: 'attribute',
firstMessageOnly: true
})
buildOptions
(
Object
-
options -
defaultOptions -
globalOptions
Normalized options passed in.
validator('alias', 'attribute')
// Becomes
validator('alias', {
alias: 'attribute'
})
Returns:
createErrorMessage
(
String
-
type -
value -
options
Used by all pre-defined validators to build an error message that is present
in
validators/message or declared in your i18n solution.
If we extended our default messages to include uniqueUsername: '{username} already exists',
we can use this method to generate our error message.
`javascript
validate(value, options) {
var exists = false;
get(options, 'description') = 'Username';
get(options, 'username') = value;
// check with server if username exists...
if(exists) {
return this.createErrorMessage('uniqueUsername', value, options);
}
return true;
}
`
If we input johndoe and that username already exists, the returned message would be 'johndoe already exists'.Parameters:
Returns:
String:
The generated message
getValue
()
Mixed
private
Wrapper method to
value that passes the necessary parametersReturns:
Mixed:
value