| Conditions | 5 |
| Paths | 16 |
| Total Lines | 23 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function validate($postData) |
||
| 23 | { |
||
| 24 | $textValidator = new \Zend\Validator\StringLength(); |
||
| 25 | $textValidator->setMin(4); |
||
| 26 | |||
| 27 | $this->messages = new \Zend\Stdlib\ArrayObject(); |
||
| 28 | if (!$textValidator->isValid($postData['title'])) { |
||
| 29 | $this->messages->offsetSet('title', array_values($textValidator->getMessages())); |
||
| 30 | } |
||
| 31 | |||
| 32 | if (!$textValidator->isValid($postData['lead'])) { |
||
| 33 | $this->messages->offsetSet('lead', array_values($textValidator->getMessages())); |
||
| 34 | } |
||
| 35 | |||
| 36 | //@TODO implement custom validator for article body (html structure) validation |
||
| 37 | if (!$textValidator->isValid($postData['body'])) { |
||
| 38 | $this->messages->offsetSet('body', array_values($textValidator->getMessages())); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ($this->messages->count()) { |
||
| 42 | throw new \Admin\Validator\ValidatorException('Data is not valid'); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 56 |