Model Object
errorsOnBase()
Signature
Section titled “Signature”errorsOnBase() — returns array
Available in: model
Category: Error Functions
Description
Section titled “Description”errorsOnBase() returns an array of all errors associated with the object as a whole, not tied to any specific property. This is useful for general errors such as system-level validations, cross-field validations, or custom errors added at the object level.
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”Example 1 — Get all base errors
<cfscript>
user = model("user").findByKey(12);
errors = user.errorsOnBase();
writeDump(errors);
</cfscript>
Returns all general errors on the user object.
Each element typically contains message, name, and type information.
Example 2 — Filter by error name
<cfscript>
errors = user.errorsOnBase("accountLocked");
writeDump(errors);
</cfscript>
Returns only base errors that have the error name accountLocked.
Example 3 — Conditional logic with base errors
<cfscript>
if (arrayLen(user.errorsOnBase()) > 0) {
writeOutput("There are general errors on this user account.");
}
</cfscript>
This can be used to block actions or display notices when object-level errors exist.
Example 4 — Iterating over base errors
<cfscript>
for (var e in user.errorsOnBase()) {
writeOutput("General error: " & e.message & "<br>");
}
</cfscript>
Loops through each object-level error and outputs its message.