ValidationReportQuery
ValidationReportQuery allows queries against the validation run report.
Synopsis
Section titled “Synopsis”class ValidationReportQuery implements IValidationReportQuery
| Implements | IValidationReportQuery |
| Since | 1.0.0 |
| Source | Validator/ValidationReportQuery.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(ValidationReport $report): mixed
Constructor.
The validation report instance.
| Parameter | Type | Description |
|---|---|---|
$report | ValidationReport | The validation report instance. |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
| [`byArgument(ValidationArgument | string |
| [`byErrorName(string | array<int, string> $name): IValidationReportQuery`](#byerrorname) |
byMaxSeverity(int $maxSeverity): IValidationReportQuery | Returns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules). |
byMinSeverity(int $minSeverity): IValidationReportQuery | Returns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules). |
| [`byValidator(string | array<int, string> $name): IValidationReportQuery`](#byvalidator) |
count(): int | Get the number of incidents matching the currently defined filter rules. |
getArguments(): array<int, ValidationArgument> | Retrieves all ValidationArgument objects which match the currently defined filter rules. |
getErrorMessages(): array<int, string> | Retrieves all error messages which match the currently defined filter rules. |
getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}> | Retrieves all error messages together with the fields that caused them, matching the currently defined filter rules. |
getErrors(): array<int, ValidationError> | Retrieves all ValidationError objects which match the currently defined filter rules. |
getIncidents(): array<int, ValidationIncident> | Retrieves all incidents which match the currently defined filter rules. |
getResult(): ?int | Retrieves the highest validation result code of the collection composed of the currently defined filter rules. |
has(): bool | Check if there are any incidents matching the currently defined filter rules. |
byArgument()
Section titled “byArgument()”public function byArgument(ValidationArgument|string|array<int, ValidationArgument|string> $argument): IValidationReportQuery
Returns a new IValidationReportQuery which returns only the incidents for the given argument (and the other existing filter rules).
The argument instance, or a parameter name, or an array of these elements.
| Parameter | Type | Description |
|---|---|---|
$argument | ValidationArgument` | string |
Returns IValidationReportQuery
byErrorName()
Section titled “byErrorName()”public function byErrorName(string|array<int, string> $name): IValidationReportQuery
Returns a new IValidationReportQuery which contains only the incidents for the given error name (and the other existing filter rules).
The name of the error, or an array of names.
| Parameter | Type | Description |
|---|---|---|
$name | `string“ | array<int, string>` |
Returns IValidationReportQuery
byMaxSeverity()
Section titled “byMaxSeverity()”public function byMaxSeverity(int $maxSeverity): IValidationReportQuery
Returns a new IValidationReportQuery which contains only the incidents of the given severity or lower (and the other existing filter rules).
The maximum severity.
| Parameter | Type | Description |
|---|---|---|
$maxSeverity | int | The maximum severity. |
Returns IValidationReportQuery
byMinSeverity()
Section titled “byMinSeverity()”public function byMinSeverity(int $minSeverity): IValidationReportQuery
Returns a new IValidationReportQuery which contains only the incidents of the given severity or higher (and the other existing filter rules).
The minimum severity.
| Parameter | Type | Description |
|---|---|---|
$minSeverity | int | The minimum severity. |
Returns IValidationReportQuery
byValidator()
Section titled “byValidator()”public function byValidator(string|array<int, string> $name): IValidationReportQuery
Returns a new IValidationReportQuery which contains only the incidents for the given validator (and the other existing filter rules).
The name of the validator, or an array of names.
| Parameter | Type | Description |
|---|---|---|
$name | `string“ | array<int, string>` |
Returns IValidationReportQuery
count()
Section titled “count()”public function count(): int
Get the number of incidents matching the currently defined filter rules.
Returns int — The number of incidents matching the currently defined filter rules.
getArguments()
Section titled “getArguments()”public function getArguments(): array<int, ValidationArgument>
Retrieves all ValidationArgument objects which match the currently defined filter rules.
Returns array``<``int``, ValidationArgument> — An array of ValidationArgument objects.
getErrorMessages()
Section titled “getErrorMessages()”public function getErrorMessages(): array<int, string>
Retrieves all error messages which match the currently defined filter rules.
Returns array``<``int``, ``string``> — An array of message strings.
getErrorMessagesWithFields()
Section titled “getErrorMessagesWithFields()”public function getErrorMessagesWithFields(): array<int, array{message: string, errors: array<int, string>}>
Retrieves all error messages together with the fields that caused them, matching the currently defined filter rules.
Returns the same array(‘message’ => string, ‘errors’ => array) structure as the deprecated ValidationManager::getErrorMessages(), but as a non-deprecated report-query accessor.
Returns array``<``int``, ``array{message: string, errors: array<int, string>}``> — An array of array(‘message’ => string, ‘errors’ => array).
getErrors()
Section titled “getErrors()”public function getErrors(): array<int, ValidationError>
Retrieves all ValidationError objects which match the currently defined filter rules.
Returns array``<``int``, ValidationError> — An array of ValidationError objects.
getIncidents()
Section titled “getIncidents()”public function getIncidents(): array<int, ValidationIncident>
Retrieves all incidents which match the currently defined filter rules.
Returns array``<``int``, ValidationIncident> — An array of ValidationIncident objects.
getResult()
Section titled “getResult()”public function getResult(): ?int
Retrieves the highest validation result code of the collection composed of the currently defined filter rules.
Returns ?``int — An Validator::* severity constant, or null if there is no result for this filter combination. Please remember to do a strict === comparison if you are comparing against Validator::SUCCESS.
public function has(): bool
Check if there are any incidents matching the currently defined filter rules.
Returns bool — Whether or not any incidents exist for the currently defined filter rules.