errors
The errors
method retrieves errors from validator.
errors()
Returns all errors for the current map instance.
var Person = new DefineMap({
name: {
validate: {
presence: true
}
}
});
var person = new Person();
person.errors();
//-> [{message: "is required", related: "name"}]
Returns
{Errors}
:
Will return undefined
if map is valid.
Otherwise, will return an array of [can-validate/types/errors].
map.errors(...propName)
Returns errors for the specified keys from current map instance.
var Person = new DefineMap({
name: {
validate: {
presence: true
}
}
age: {
validate: {
presence: true,
numericality: true
}
}
});
var person = new Person();
person.errors('name');
//-> [{message: "is required", related: "name"}]
Parameters
- propName
{Array<string>}
:The property key to retrieve errors for.
Returns
{Errors}
:
Will return undefined
if map is valid.
Otherwise, will return an array of [can-validate/types/errors].