Skip to content

Model Object

errorCount()

errorCount() — returns numeric

Available in: model Category: Error Functions

Returns the number of errors this object has associated with it. Specify property or name if you wish to count only specific errors.

NameTypeRequiredDefaultDescription
propertystringno—Specify a property name here if you want to count only errors set on a specific property.
namestringno—Specify an error name here if you want to count only errors set with a specific error name.
// 1. Check the total number of errors on an object
if (author.errorCount() GTE 10) {
    // Too many errors — bail out early
}

// 2. Check how many errors are associated with a specific property
if (author.errorCount(property="email") gt 0) {
    // The email property has at least one error
}

// 3. Count errors that were set with a specific error name
count = author.errorCount(name="invalidFormat");
// count -> 2 (two errors share the "invalidFormat" name)