Files
lucent-laravel/src/Schema/Validator/ValidatorException.php
T

33 lines
721 B
PHP
Raw Normal View History

2023-10-02 23:10:49 +03:00
<?php
namespace Lucent\Schema\Validator;
use Exception;
final class ValidatorException extends Exception
{
private array $validatorErrors;
// Redefine the exception so message isn't optional
public function __construct(array $message, int $code = 0, Exception $previous = null)
{
// make sure everything is assigned properly
$this->validatorErrors = $message;
parent::__construct("You have one or more validation errors", $code, $previous);
}
public function getValidatorErrors(): array
{
return $this->validatorErrors;
}
public function getFirstValidatorError(): array
{
return (array)array_shift($this->validatorErrors);
}
}