| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentForm\App\Services\Parser; |
| 4 | 4 | |
| 5 | -use FluentForm\App\Services\ConditionAssesor; | |
| 6 | 5 | use FluentForm\Framework\Helpers\ArrayHelper as Arr; |
| 7 | 6 | |
| 8 | 7 | class Validations |
| 9 | 8 | { |
| @@ -55,8 +54,21 @@ | ||
| 55 | 54 | */ |
| 56 | 55 | protected $messages = []; |
| 57 | 56 | |
| 58 | 57 | /** |
| 58 | + * Rules the validator has no method for. | |
| 59 | + * | |
| 60 | + * Selection limits are counted against the field's own options in | |
| 61 | + * Helper::validateSelectionLimits(), which runs later in the submission with | |
| 62 | + * the raw field settings in hand — the only place the configured (or global) | |
| 63 | + * message for the breach can be resolved. Emitting them here too would lean | |
| 64 | + * on the validator silently ignoring rules it does not recognise. | |
| 65 | + * | |
| 66 | + * @var array | |
| 67 | + */ | |
| 68 | + protected $rulesHandledElsewhere = ['min_selection', 'max_selection']; | |
| 69 | + | |
| 70 | + /** | |
| 59 | 71 | * The validation extractor constructor. |
| 60 | 72 | * |
| 61 | 73 | * @param array $formFields |
| 62 | 74 | * @param array $formData |
| @@ -86,8 +98,12 @@ | ||
| 86 | 98 | // If the field is a repeater we'll set some settings here. |
| 87 | 99 | $this->setRepeater($fieldName, $field); |
| 88 | 100 | |
| 89 | 101 | foreach ($rules as $ruleName => $rule) { |
| 102 | + if (in_array($ruleName, $this->rulesHandledElsewhere, true)) { | |
| 103 | + continue; | |
| 104 | + } | |
| 105 | + | |
| 90 | 106 | if ($this->shouldNotSkipThisRule($rule, $fieldValue, $hasRequiredRule)) { |
| 91 | 107 | $this->prepareValidations($fieldName, $ruleName, $rule); |
| 92 | 108 | } |
| 93 | 109 | } |