@@ -12,7 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function validate($value) |
| 14 | 14 | { |
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 15 | + if(strlen($value) > $this->max_length) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | return parent::validate($value); |
| 17 | 19 | } |
| 18 | 20 | } |
@@ -34,10 +34,18 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | protected function validate($value){ |
| 37 | - if (is_null($value) && (!$this->null)) return false; |
|
| 38 | - if (empty($value) && (!$this->blank)) return false; |
|
| 39 | - if (!empty($this->choices) && !in_array($value, $this->choices)) return false; |
|
| 40 | - if (!empty($this->validators)) return $this->validate_with_validators($value); |
|
| 37 | + if (is_null($value) && (!$this->null)) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | + if (empty($value) && (!$this->blank)) { |
|
| 41 | + return false; |
|
| 42 | + } |
|
| 43 | + if (!empty($this->choices) && !in_array($value, $this->choices)) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 46 | + if (!empty($this->validators)) { |
|
| 47 | + return $this->validate_with_validators($value); |
|
| 48 | + } |
|
| 41 | 49 | |
| 42 | 50 | return true; |
| 43 | 51 | } |
@@ -45,7 +53,9 @@ discard block |
||
| 45 | 53 | |
| 46 | 54 | private function validate_with_validators($value){ |
| 47 | 55 | foreach($this->validators as $validator){ |
| 48 | - if (!$validator($value)) return false; |
|
| 56 | + if (!$validator($value)) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 49 | 59 | } |
| 50 | 60 | return true; |
| 51 | 61 | } |
@@ -12,7 +12,9 @@ |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function validate($value){ |
| 15 | - if(strlen($value) > $this->max_length) return false; |
|
| 15 | + if(strlen($value) > $this->max_length) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | return parent::validate($value); |
| 17 | 19 | } |
| 18 | 20 | } |
| 19 | 21 | \ No newline at end of file |
@@ -14,7 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function validate($value) |
| 16 | 16 | { |
| 17 | - if (!is_a($value, $this->child)) return false; |
|
| 17 | + if (!is_a($value, $this->child)) { |
|
| 18 | + return false; |
|
| 19 | + } |
|
| 18 | 20 | return parent::validate($value); |
| 19 | 21 | } |
| 20 | 22 | } |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public function validate($value){ |
| 11 | - if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) return false; |
|
| 11 | + if (!preg_match("/\d{4}-\d{2}-\d{2}/", $value)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 12 | 14 | return parent::validate($value); |
| 13 | 15 | } |
| 14 | 16 | |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public function validate($value){ |
| 11 | - if(!is_numeric($value)) return false; |
|
| 11 | + if(!is_numeric($value)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 12 | 14 | return parent::validate($value); |
| 13 | 15 | } |
| 14 | 16 | } |
| 15 | 17 | \ No newline at end of file |
@@ -9,7 +9,9 @@ |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public function validate($value){ |
| 12 | - if(!is_numeric($value)) return false; |
|
| 12 | + if(!is_numeric($value)) { |
|
| 13 | + return false; |
|
| 14 | + } |
|
| 13 | 15 | return parent::validate($value); |
| 14 | 16 | } |
| 15 | 17 | } |
| 16 | 18 | \ No newline at end of file |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | public function validate($value){ |
| 11 | - if (!preg_match("/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/", $value)) return false; |
|
| 11 | + if (!preg_match("/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/", $value)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 12 | 14 | return parent::validate($value); |
| 13 | 15 | } |
| 14 | 16 | } |
| 15 | 17 | \ No newline at end of file |
@@ -11,7 +11,9 @@ |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | public function validate($value){ |
| 14 | - if(!is_array(json_decode($value, true))) return false; |
|
| 14 | + if(!is_array(json_decode($value, true))) { |
|
| 15 | + return false; |
|
| 16 | + } |
|
| 15 | 17 | return parent::validate($value); |
| 16 | 18 | } |
| 17 | 19 | } |
| 18 | 20 | \ No newline at end of file |