Skip to content

ValidationIncident

ValidationIncident is erroneous result of an validation run.

class ValidationIncident implements ResetInterface

ImplementsResetInterface
Since1.0.0
SourceValidator/ValidationIncident.php

public function __construct(Validator $validator, int $severity = Quiote\Validator\Validator::ERROR): mixed

Constructor

The severity of the incident

ParameterTypeDescription
$validatorValidatorThe validator which caused this incident (null for errors thrown not in the validation)
$severityintThe severity of the incident

Returns mixed

MethodDescription
addError(ValidationError $error): voidAdds an error to this incident.
getArguments(): array<string, ValidationArgument>Retrieves a list of all erroneous arguments of this incident.
getErrors(): array<int, ValidationError>Retrieves the errors of this incident.
getFields(): array<int, string>Retrieves a list of all fields of all the containing errors.
getSeverity(): intRetrieves the severity of this incident.
getValidator(): ?ValidatorRetrieves the validator of this incident.
reset(): voidReturns the incident to its initial state for reuse across requests.
setErrors(array<int, ValidationError> $errors): voidSets the errors of this incident.
setSeverity(int $severity): intSets the severity of this incident.
setValidator(?Validator $validator): ?ValidatorSets the validator of this incident.

public function addError(ValidationError $error): void

Adds an error to this incident.

The error.

ParameterTypeDescription
$errorValidationErrorThe error.

public function getArguments(): array<string, ValidationArgument>

Retrieves a list of all erroneous arguments of this incident.

Returns array``<``string``, ValidationArgument> — An array of ValidationArgument.

public function getErrors(): array<int, ValidationError>

Retrieves the errors of this incident.

Returns array``<``int``, ValidationError> — The errors.

public function getFields(): array<int, string>

Retrieves a list of all fields of all the containing errors.

Returns array``<``int``, ``string``> — An array of field names.

public function getSeverity(): int

Retrieves the severity of this incident.

Returns int — The severity.

public function getValidator(): ?Validator

Retrieves the validator of this incident.

Returns ?Validator — The validator.

public function reset(): void

Returns the incident to its initial state for reuse across requests.

Detaches the validator that raised it, drops the collected errors and puts the severity back to the default Validator::ERROR. The discarded errors are not themselves reset.

public function setErrors(array<int, ValidationError> $errors): void

Sets the errors of this incident.

An array of ValidationErrors.

ParameterTypeDescription
$errorsarray``<``int``, ValidationError>An array of ValidationErrors.

public function setSeverity(int $severity): int

Sets the severity of this incident.

The severity.

ParameterTypeDescription
$severityintThe severity.

Returns int

public function setValidator(?Validator $validator): ?Validator

Sets the validator of this incident.

The validator.

ParameterTypeDescription
$validator?ValidatorThe validator.

Returns ?Validator