Final Class Yiisoft\RequestModel\RequestValidationException
| Inheritance | Yiisoft\RequestModel\RequestValidationException » RuntimeException |
|---|
Public Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| MESSAGE | 'Request model validation error' | Yiisoft\RequestModel\RequestValidationException |
Method Details
| public mixed __construct ( string[] $errors ) | ||
| $errors | string[] | |
public function __construct(
private array $errors
) {
parent::__construct(self::MESSAGE);
}
| public string|null getFirstError ( ) |
public function getFirstError(): ?string
{
$errors = $this->getFirstErrors();
return $errors === [] ? null : reset($errors);
}
| public array getFirstErrors ( ) |
public function getFirstErrors(): array
{
if (empty($this->errors)) {
return [];
}
$result = [];
foreach ($this->errors as $name => $errors) {
if (!empty($errors)) {
$result[$name] = reset($errors);
}
}
return $result;
}
Signup or Login in order to comment.