Source of file ValidatorException.php
Size: 1,231 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/Validator/Exception/ValidatorException.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\Validator\Exception; use Bluz\Application\Exception\BadRequestException; /** * Validator Exception * * @package Bluz\Validator\Exception * @author Anton Shevchuk */ class ValidatorException extends BadRequestException { /** * @var string exception message */ protected $message = 'Invalid Arguments'; /** * @var array of error's messages */ protected $errors = []; /** * @return array */ public function getErrors(): array { return $this->errors; } /** * @param array $errors */ public function setErrors(array $errors) { $this->errors = $errors; } /** * Add Error by field name * * @param string $name * @param string $message * * @return void */ public function setError($name, $message) { $this->errors[$name] = $message; } /** * Has errors? * * @return bool */ public function hasErrors() : bool { return (bool)count($this->errors); } } |