Skip to content

UTIL_ValidationRule.ValidationResult

Class

apex
global class UTIL_ValidationRule.ValidationResult

Result of validating a single record. Contains all validation errors/warnings for that record.

Since: 1.0


Properties

PropertyDescription
global List errorsList of validation errors/warnings for this record.
global Boolean isValidTrue if the record passed all validation rules.

Fields

FieldDescription
global Id recordIdThe record ID (available in all contexts except before insert).
global Integer recordIndexThe index of the record in the trigger list (for before insert correlation).

Methods

MethodDescription
global String getErrorMessage()Gets concatenated error message string.
global List getErrorsBySeverity(String severity)Gets errors filtered by severity.
global ValidationResult(Integer recordIndex, Id recordId)Constructs a new ValidationResult for the given record.

Property Details

errors

apex
global List<UTIL_ValidationRule.ValidationError> errors

Type: List

List of validation errors/warnings for this record.

Since:

Example:

isValid

apex
global Boolean isValid

Type: Boolean

True if the record passed all validation rules.

Since:

Example:


Method Details

ValidationResult

apex
global ValidationResult(Integer recordIndex, Id recordId)

Constructs a new ValidationResult for the given record.

Parameters:

  • recordIndex (Integer) - The index in the trigger list
  • recordId (Id) - The record ID (may be null for before insert)

Since: 1.0

Example:

apex
UTIL_ValidationRule.ValidationResult instance = new UTIL_ValidationRule.ValidationResult(10, recordId);

getErrorMessage

apex
global String getErrorMessage()

Gets concatenated error message string.

Returns: String - All error messages joined by newlines

Since: 1.0

Example:

apex
String result = instance.getErrorMessage();

getErrorsBySeverity

apex
global List<UTIL_ValidationRule.ValidationError> getErrorsBySeverity(String severity)

Gets errors filtered by severity.

Parameters:

  • severity (String) - The severity to filter by ('Error' or 'Warning')

Returns: UTIL_ValidationRule.ValidationError - List of errors matching the severity

Since: 1.0

Example:

apex
List<ValidationError> result = instance.getErrorsBySeverity('Error');

Field Details

recordId

apex
global Id recordId

Type: Id

The record ID (available in all contexts except before insert).

Since: 1.0

Example:

apex
Id value = instance.recordId;

recordIndex

apex
global Integer recordIndex

Type: Integer

The index of the record in the trigger list (for before insert correlation).

Since: 1.0

Example:

apex
Integer value = instance.recordIndex;