| @@ 226-238 (lines=13) @@ | ||
| 223 | } |
|
| 224 | ||
| 225 | break; |
|
| 226 | case 'minLength': |
|
| 227 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 228 | throw new \InvalidArgumentException("Invalid min length validation rule[{$ruleContents}]"); |
|
| 229 | } |
|
| 230 | ||
| 231 | if (mb_strlen($value) < $ruleContents) { |
|
| 232 | $errorMsg = $this->translator->trans( |
|
| 233 | 'errorFieldMustBeMinXLength', |
|
| 234 | ['%field%' => $fieldName, '%numberOf%' => $ruleContents] |
|
| 235 | ); |
|
| 236 | } |
|
| 237 | ||
| 238 | break; |
|
| 239 | case 'maxLength': |
|
| 240 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 241 | throw new \InvalidArgumentException("Invalid max length validation rule[{$ruleContents}]"); |
|
| @@ 239-251 (lines=13) @@ | ||
| 236 | } |
|
| 237 | ||
| 238 | break; |
|
| 239 | case 'maxLength': |
|
| 240 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 241 | throw new \InvalidArgumentException("Invalid max length validation rule[{$ruleContents}]"); |
|
| 242 | } |
|
| 243 | ||
| 244 | if ((((string) $value) !== '') && mb_strlen($value) > $ruleContents) { |
|
| 245 | $errorMsg = $this->translator->trans( |
|
| 246 | 'errorFieldMustBeMaxXLength', |
|
| 247 | ['%field%' => $fieldName, '%numberOf%' => $ruleContents] |
|
| 248 | ); |
|
| 249 | } |
|
| 250 | ||
| 251 | break; |
|
| 252 | case 'length': |
|
| 253 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 254 | throw new \InvalidArgumentException("Invalid length validation rule[{$ruleContents}]"); |
|
| @@ 252-264 (lines=13) @@ | ||
| 249 | } |
|
| 250 | ||
| 251 | break; |
|
| 252 | case 'length': |
|
| 253 | if (!is_int($ruleContents) || $ruleContents < 1) { |
|
| 254 | throw new \InvalidArgumentException("Invalid length validation rule[{$ruleContents}]"); |
|
| 255 | } |
|
| 256 | ||
| 257 | if ((((string) $value) !== '') && mb_strlen($value) !== $ruleContents) { |
|
| 258 | $errorMsg = $this->translator->trans( |
|
| 259 | 'errorFieldMustBeXLength', |
|
| 260 | ['%field%' => $fieldName, '%numberOf%' => $ruleContents] |
|
| 261 | ); |
|
| 262 | } |
|
| 263 | ||
| 264 | break; |
|
| 265 | case 'regexp': |
|
| 266 | if (!$ruleContents) { |
|
| 267 | throw new \InvalidArgumentException("Invalid regexp validation rule[{$ruleContents}]"); |
|