Skip to content

UTIL_ValidationRule.ValidationError

Class

apex
global class UTIL_ValidationRule.ValidationError

Represents a single validation error or warning.

Since: 1.0


Fields

FieldDescription
global String fieldNameThe field API name to display the error on (may be null for page-level).
global String groupNameThe validation rule group DeveloperName.
global String messageThe error message to display.
global Id recordIdThe record ID (available except in before insert).
global Integer recordIndexThe record index in the trigger list (for before insert).
global String ruleNameThe DeveloperName of the validation rule that failed.
global String severityThe severity ('Error' or 'Warning').
global Boolean shadowModeTrue if this error is from a rule in shadow mode.

Methods

MethodDescription
global ValidationError(String ruleName, String message, String fieldName, String severity)Constructs a new ValidationError.

Method Details

ValidationError

apex
global ValidationError(String ruleName, String message, String fieldName, String severity)

Constructs a new ValidationError.

Parameters:

  • ruleName (String) - The rule DeveloperName
  • message (String) - The error message
  • fieldName (String) - The field API name (may be null)
  • severity (String) - The severity level

Since: 1.0

Example:

apex
UTIL_ValidationRule.ValidationError instance = new UTIL_ValidationRule.ValidationError('myName', 'An error occurred', 'myName', 'Error');

Field Details

fieldName

apex
@AuraEnabled global String fieldName

Type: String

The field API name to display the error on (may be null for page-level).

Since: 1.0

Example:

apex
String value = instance.fieldName;

groupName

apex
@AuraEnabled global String groupName

Type: String

The validation rule group DeveloperName.

Since: 1.0

Example:

apex
String value = instance.groupName;

message

apex
@AuraEnabled global String message

Type: String

The error message to display.

Since: 1.0

Example:

apex
String value = instance.message;

recordId

apex
@AuraEnabled global Id recordId

Type: Id

The record ID (available except in before insert).

Since: 1.0

Example:

apex
Id value = instance.recordId;

recordIndex

apex
@AuraEnabled global Integer recordIndex

Type: Integer

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

Since: 1.0

Example:

apex
Integer value = instance.recordIndex;

ruleName

apex
@AuraEnabled global String ruleName

Type: String

The DeveloperName of the validation rule that failed.

Since: 1.0

Example:

apex
String value = instance.ruleName;

severity

apex
@AuraEnabled global String severity

Type: String

The severity ('Error' or 'Warning').

Since: 1.0

Example:

apex
String value = instance.severity;

shadowMode

apex
@AuraEnabled global Boolean shadowMode

Type: Boolean

True if this error is from a rule in shadow mode.

Since: 1.0

Example:

apex
Boolean value = instance.shadowMode;