0 follower

Final Class Yiisoft\RequestModel\RequestValidationException

InheritanceYiisoft\RequestModel\RequestValidationException » RuntimeException

Constants

Hide inherited constants

Constant Value Description Defined By
MESSAGE 'Request model validation error' Yiisoft\RequestModel\RequestValidationException

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string[] $errors )
$errors string[]

                public function __construct(
    private array $errors
) {
    parent::__construct(self::MESSAGE);
}

            
getErrors() public method

public array getErrors ( )

                public function getErrors(): array
{
    return $this->errors;
}

            
getFirstError() public method

public string|null getFirstError ( )

                public function getFirstError(): ?string
{
    $errors = $this->getFirstErrors();
    return $errors === [] ? null : reset($errors);
}

            
getFirstErrors() public method

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;
}