| @@ 198-211 (lines=14) @@ | ||
| 195 | } |
|
| 196 | ||
| 197 | break; |
|
| 198 | case 'min': |
|
| 199 | if (!is_numeric($ruleContents)) { |
|
| 200 | throw new \InvalidArgumentException("Invalid min validation rule[{$ruleContents}]"); |
|
| 201 | } |
|
| 202 | ||
| 203 | if (!is_numeric($value) || $value < $ruleContents) { |
|
| 204 | $fieldName = |
|
| 205 | $errorMsg = $this->translator->trans( |
|
| 206 | 'errorFieldMustBeMinNumber', |
|
| 207 | ['%field%' => $fieldName, '%number%' => $ruleContents] |
|
| 208 | ); |
|
| 209 | } |
|
| 210 | ||
| 211 | break; |
|
| 212 | case 'max': |
|
| 213 | if (!is_numeric($ruleContents)) { |
|
| 214 | throw new \InvalidArgumentException("Invalid max validation rule[{$ruleContents}]"); |
|
| @@ 212-227 (lines=16) @@ | ||
| 209 | } |
|
| 210 | ||
| 211 | break; |
|
| 212 | case 'max': |
|
| 213 | if (!is_numeric($ruleContents)) { |
|
| 214 | throw new \InvalidArgumentException("Invalid max validation rule[{$ruleContents}]"); |
|
| 215 | } |
|
| 216 | ||
| 217 | if (!is_numeric($value) || $value > $ruleContents) { |
|
| 218 | $errorMsg = $this->translator->trans( |
|
| 219 | 'errorFieldMustBeMaxNumber', |
|
| 220 | [ |
|
| 221 | '%field%' => $fieldName, |
|
| 222 | '%number%' => $ruleContents |
|
| 223 | ] |
|
| 224 | ); |
|
| 225 | } |
|
| 226 | ||
| 227 | break; |
|
| 228 | case 'minLength': |
|
| 229 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 230 | throw new \InvalidArgumentException("Invalid min length validation rule[{$ruleContents}]"); |
|