API reference / Quittio \ Core \ Validation
ValidationResult
final readonly class in quittio/core · implements JsonSerializable
Quittio\Core\Validation\ValidationResult · Source
Result of a validation run.
Properties#
| Property | Type | Description |
|---|---|---|
$levels readonly | list<ValidationLevel> | levels that were checked |
$messages readonly | list<ValidationMessage> |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->byLevel() | |
->errors() | |
->has() | |
->hasWarnings() | |
->infos() | |
->isValid() | |
->jsonSerialize() | |
->merge() | |
->toArray() | |
->toHtml() | Readable validation report as a self-contained HTML fragment. |
->warnings() |
__construct()#
public function __construct(
list<ValidationMessage> $messages = [],
list<ValidationLevel> $levels = [],
)| Parameter | Type | Description |
|---|---|---|
$messages | list<ValidationMessage> = [] | |
$levels | list<ValidationLevel> = [] | levels that were checked |
byLevel()#
public function byLevel(ValidationLevel $level): list<ValidationMessage>| Parameter | Type | Description |
|---|---|---|
$level | ValidationLevel |
- Returns
list<ValidationMessage>
errors()#
public function errors(): list<ValidationMessage>- Returns
list<ValidationMessage>
has()#
public function has(string $code): bool| Parameter | Type | Description |
|---|---|---|
$code | string |
- Returns
bool
hasWarnings()#
public function hasWarnings(): bool- Returns
bool
infos()#
public function infos(): list<ValidationMessage>- Returns
list<ValidationMessage>
isValid()#
public function isValid(): bool- Returns
bool
jsonSerialize()#
public function jsonSerialize(): array<string, mixed>- Returns
array<string, mixed>
merge()#
public function merge(self $other): self| Parameter | Type | Description |
|---|---|---|
$other | self |
- Returns
self
toArray()#
public function toArray(): array{valid: bool, levels: list<string>, messages: list<array<string, string|null>>}- Returns
array{valid: bool, levels: list<string>, messages: list<array<string, string|null>>}
toHtml()#
public function toHtml(): stringReadable validation report as a self-contained HTML fragment.
- Returns
string
warnings()#
public function warnings(): list<ValidationMessage>- Returns
list<ValidationMessage>