| Conditions | 4 |
| Paths | 6 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 58 | public function validate() :bool |
||
| 59 | { |
||
| 60 | foreach ($this->validators as $validator) { |
||
| 61 | |||
| 62 | $result = $validator->process($this->field->getValue()); |
||
| 63 | |||
| 64 | if (!$result) { |
||
| 65 | $this->messages[] = $validator->getMessage(); |
||
| 66 | } |
||
| 67 | |||
| 68 | } |
||
| 69 | |||
| 70 | if (!empty($this->messages)) { |
||
| 71 | // Access first one because every validator can return its field object |
||
| 72 | $this->validators[0]->getField()->setErrorMessages($this->messages); |
||
| 73 | $this->validators[0]->getField()->addAttribute('class', 'error'); |
||
| 74 | return false; |
||
| 75 | } |
||
| 76 | |||
| 77 | return true; |
||
| 78 | } |
||
| 79 | |||
| 80 | } |