1 | <?php |
||
2 | /** |
||
3 | * @author Nurlan Mukhanov <[email protected]> |
||
4 | * @copyright 2022 Nurlan Mukhanov |
||
5 | * @license https://en.wikipedia.org/wiki/MIT_License MIT License |
||
6 | * @link https://github.com/Falseclock/service-layer |
||
7 | */ |
||
8 | |||
9 | declare(strict_types=1); |
||
10 | |||
11 | namespace Falseclock\Service\Validation; |
||
12 | |||
13 | abstract class ValidatorImpl implements Validator |
||
14 | { |
||
15 | /** |
||
16 | * @var mixed Значение переменной устанавливается динамически |
||
17 | * @see ValidationProcessImpl::validate() |
||
18 | */ |
||
19 | public $value; |
||
20 | /** @var string|null Error message */ |
||
21 | protected $message; |
||
22 | /** @var bool */ |
||
23 | protected $nullable = false; |
||
24 | |||
25 | /** |
||
26 | * Validator constructor. |
||
27 | * |
||
28 | * @param string|null $message |
||
29 | */ |
||
30 | public function __construct(string $message, ?bool $nullable = false) |
||
31 | { |
||
32 | $this->nullable = $nullable; |
||
33 | $this->message = $message; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return ValidatorError |
||
38 | */ |
||
39 | public function getMessage(): ValidatorError |
||
40 | { |
||
41 | return new ValidatorError($this->message, $this->value); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
42 | } |
||
43 | } |
||
44 |