Conditions | 4 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
49 | public function validate() :bool |
||
50 | { |
||
51 | foreach ($this->validators as $validator) { |
||
52 | |||
53 | $result = $validator->process($this->field->getValue()); |
||
54 | |||
55 | if (!$result) { |
||
56 | $this->messages[] = $validator->getMessage(); |
||
57 | } |
||
58 | |||
59 | } |
||
60 | |||
61 | if (!empty($this->messages)) { |
||
62 | // Access first one because every validator can return its field object |
||
63 | $this->validators[0]->getField()->setErrorMessages($this->messages); |
||
64 | $this->validators[0]->getField()->addAttribute('class', 'error'); |
||
65 | return false; |
||
66 | } |
||
67 | |||
68 | return true; |
||
69 | } |
||
70 | |||
71 | } |