class ValidationException extends Exception (View source)

Exception thrown by DataObject::write if validation fails. By throwing an exception rather than a user error, the exception can be caught in unit tests and as such can be used as a successful test.

Properties

protected ValidationResult $result

The contained ValidationResult related to this error

Methods

public
__construct(ValidationResult|string $result = null, string|int $message = null, int $code = 0)

Construct a new ValidationException with an optional ValidationResult object

public
getResult()

Retrieves the ValidationResult related to this error

Details

__construct(ValidationResult|string $result = null, string|int $message = null, int $code = 0)

Construct a new ValidationException with an optional ValidationResult object

Parameters

ValidationResult|string $result

The ValidationResult containing the failed result. Can be substituted with an error message instead if no ValidationResult exists.

string|int $message

The error message. If $result was given the message string rather than a ValidationResult object then this will have the error code number.

int $code

The error code number, if not given in the second parameter

ValidationResult getResult()

Retrieves the ValidationResult related to this error

Return Value

ValidationResult