Model Object
errorsOnBase()
Signature
Section titled “Signature”errorsOnBase() — returns array
Available in: model
Category: Error Functions
Description
Section titled “Description”Returns an array of all errors associated with the object as a whole (not related to any specific property).
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | no | — | Specify an error name here to only return errors for that error name. |
Examples
Section titled “Examples”// 1. Get all general (base) errors for a model object after validation
user = model("User").new(params.user);
user.valid();
errors = user.errorsOnBase();
// errors -> [{property: "", message: "Account has been suspended", name: ""}]
// 2. Filter base errors by a specific error name
user.addErrorToBase(message="Account has been suspended", name="suspended");
user.addErrorToBase(message="Please accept the terms", name="terms");
suspendedErrors = user.errorsOnBase(name="suspended");
// suspendedErrors -> [{property: "", message: "Account has been suspended", name: "suspended"}]
// 3. Check for base errors and display them
errors = user.errorsOnBase();
if (arrayLen(errors)) {
for (e in errors) {
writeOutput(e.message);
}
}