|
21 | 21 | */ |
22 | 22 | class FieldValidation extends AbstractValidation |
23 | 23 | { |
24 | | - /** |
25 | | - * @return array |
26 | | - */ |
27 | | - // public function rules() |
28 | | - // { |
29 | | - // return [ |
30 | | - // ['field', 'required|string:5,10|...', ...], |
31 | | - // ['field0', ['required', 'string:5,10'], ...], |
32 | | - // ['field1', 'rule1|rule2|...', ...], |
33 | | - // ['field2', 'rule1|rule3|...', ...], |
34 | | - // ]; |
35 | | - // } |
| 24 | + /* |
| 25 | + public function rules() |
| 26 | + { |
| 27 | + return [ |
| 28 | + ['field', 'required|string:5,10|...', ...], |
| 29 | + ['field0', ['required', 'string:5,10'], ...], |
| 30 | + ['field1', 'rule1|rule2|...', ...], |
| 31 | + ['field2', 'rule1|rule3|...', ...], |
| 32 | + ]; |
| 33 | + } |
| 34 | + */ |
36 | 35 |
|
37 | 36 | /** |
38 | 37 | * @return \Generator |
@@ -95,37 +94,37 @@ protected function collectRules() |
95 | 94 | */ |
96 | 95 | protected function parseRule(string $rule, array $row): array |
97 | 96 | { |
98 | | - $rule = trim($rule, ': '); |
| 97 | + $rule = \trim($rule, ': '); |
99 | 98 |
|
100 | 99 | if (false === \strpos($rule, ':')) { |
101 | 100 | $row[0] = $rule; |
102 | 101 | return $row; |
103 | 102 | } |
104 | 103 |
|
105 | 104 | list($name, $args) = \explode(':', $rule, 2); |
106 | | - $args = trim($args, ', '); |
| 105 | + $args = \trim($args, ', '); |
107 | 106 | $row[0] = $name; |
108 | 107 |
|
109 | 108 | switch ($name) { |
110 | 109 | case 'in': |
111 | 110 | case 'enum': |
112 | 111 | case 'ontIn': |
113 | | - $row[] = \array_map('trim', explode(',', $args)); |
| 112 | + $row[] = \array_map('trim', \explode(',', $args)); |
114 | 113 | break; |
115 | 114 |
|
116 | 115 | case 'size': |
117 | 116 | case 'range': |
118 | 117 | case 'string': |
119 | 118 | case 'between': |
120 | | - if (strpos($args, ',')) { |
121 | | - list($row['min'], $row['max']) = \array_map('trim', explode(',', $args, 2)); |
| 119 | + if (\strpos($args, ',')) { |
| 120 | + list($row['min'], $row['max']) = \array_map('trim', \explode(',', $args, 2)); |
122 | 121 | } else { |
123 | 122 | $row['min'] = $args; |
124 | 123 | } |
125 | 124 | break; |
126 | 125 | default: |
127 | | - $args = strpos($args, ',') ? \array_map('trim', explode(',', $args)) : [$args]; |
128 | | - $row = array_merge($row, $args); |
| 126 | + $args = \strpos($args, ',') ? \array_map('trim', \explode(',', $args)) : [$args]; |
| 127 | + $row = \array_merge($row, $args); |
129 | 128 | break; |
130 | 129 | } |
131 | 130 |
|
|
0 commit comments