@@ -15,8 +15,9 @@ |
||
| 15 | 15 | protected $validation; |
| 16 | 16 | |
| 17 | 17 | public function __construct($name) { |
| 18 | - if (!$this->isValidName($name)) |
|
| 19 | - throw new InvalidFieldNameException(); |
|
| 18 | + if (!$this->isValidName($name)) { |
|
| 19 | + throw new InvalidFieldNameException(); |
|
| 20 | + } |
|
| 20 | 21 | $this->name = $name; |
| 21 | 22 | |
| 22 | 23 | $this->validation = new Validation(); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | protected $validators = []; |
| 14 | 14 | |
| 15 | 15 | public function addValidator(Validator ...$validators) { |
| 16 | - foreach($validators as $v) |
|
| 16 | + foreach ($validators as $v) |
|
| 17 | 17 | array_push($this->validators, $v); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -13,15 +13,17 @@ |
||
| 13 | 13 | protected $validators = []; |
| 14 | 14 | |
| 15 | 15 | public function addValidator(Validator ...$validators) { |
| 16 | - foreach($validators as $v) |
|
| 17 | - array_push($this->validators, $v); |
|
| 16 | + foreach($validators as $v) { |
|
| 17 | + array_push($this->validators, $v); |
|
| 18 | + } |
|
| 18 | 19 | } |
| 19 | 20 | |
| 20 | 21 | public function validate($value): Result { |
| 21 | 22 | $messages = []; |
| 22 | 23 | foreach ($this->validators as $validator) { |
| 23 | - if (!$validator->validate($value)) |
|
| 24 | - array_push($messages, $validator->getDescription()); |
|
| 24 | + if (!$validator->validate($value)) { |
|
| 25 | + array_push($messages, $validator->getDescription()); |
|
| 26 | + } |
|
| 25 | 27 | } |
| 26 | 28 | return count($messages) |
| 27 | 29 | ? new Validation\InvalidResult($messages) |