| Total Complexity | 8 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 8 | class FileFieldMinRule extends AbstractMediaFieldRule |
||
| 9 | { |
||
| 10 | public function validate($attribute, $value, $params, $validator): bool |
||
| 11 | { |
||
| 12 | $value = $this->normalizePayload($value); |
||
| 13 | |||
| 14 | foreach([MediaRequest::NEW, MediaRequest::REPLACE] as $type) { |
||
| 15 | foreach($value[$type] as $file) { |
||
| 16 | if($file && false !== $this->validateMin($attribute, $file, $params)) { |
||
| 17 | return true; |
||
| 18 | } |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | $validator->setCustomMessages([ |
||
| 23 | 'filefield_min' => 'De :attribute is te klein en dient groter te zijn dan ' . implode(',',$params) .'Kb.', |
||
| 24 | ]); |
||
| 25 | |||
| 26 | if(!isset($validator->customAttributes[$attribute])) { |
||
| 27 | $validator->addCustomAttributes([ |
||
| 28 | $attribute => 'afbeelding', |
||
| 29 | ]); |
||
| 30 | } |
||
| 31 | |||
| 32 | |||
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function validateMin($attribute, $value, $parameters) |
||
| 43 | } |
||
| 44 | } |
||
| 45 |