Model Object
errorsOn()
Signature
Section titled “Signature”errorsOn() — returns array
Available in: model
Category: Error Functions
Description
Section titled “Description”Returns an array of all errors associated with the supplied property (and error name if passed in).
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
property | string | yes | — | Specify the property name to return errors for here. |
name | string | no | — | If you want to return only errors on the property set with a specific error name you can specify it here. |
Examples
Section titled “Examples”// 1. Get all errors associated with the emailAddress property
errors = user.errorsOn("emailAddress");
// errors -> [{property: "emailAddress", message: "is invalid", name: ""}, ...]
// 2. Get only errors on emailAddress that were set with a specific error name
errors = user.errorsOn(property="emailAddress", name="formatCheck");
// errors -> [{property: "emailAddress", message: "must be a valid email", name: "formatCheck"}]
// 3. Check errors on a property and loop over them
errors = user.errorsOn("username");
for (error in errors) {
writeOutput(error.message);
}