errors
can.Map.validations.prototype.errors
observe.errors(attrs, newVal)
Parameters
-
attrs
{Array<String>}
OptionalAn optional list of attributes to get errors for:
task.errors(['dueDate','name']);
Or it can take a single attr name like:
task.errors('dueDate')
-
newVal
{Object}
OptionalAn optional new value to test setting on the observe. If
newVal
is provided, it returns the errors on the observe ifnewVal
was set.
Returns
{Object<String,Array<String>>}
an object of attributeName : [errors] like:
task.errors() // -> {dueDate: ["can't be empty"]}
or null
if there are no errors.
Runs the validations on this observe. You can also pass it an array of attributes to run only those attributes. It returns nothing if there are no errors, or an object of errors by attribute.
To use validations, it's suggested you use the observe/validations plugin.