Skip to content

Commit

Permalink
bug #33834 [Validator] Fix ValidValidator group cascading usage (fanc…
Browse files Browse the repository at this point in the history
…yweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Fix ValidValidator group cascading usage

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

`$this->context->getGroup()` returns `string` or `null`.

`ContextualValidatorInterface::validate()` 3rd argument accepts an array but it must not contain `null` (its contract doesn't allow it). If it does, it will fail in `RecursiveContextualValidator::validateInGroup()` for example because of the `string` scalar type on the `$group` argument. (on 4.4)

Note that in our "common" usage of the `Valid` constraint, the group in its validator will never be `null` because this constraint has a special treatment. However, if this validator is reused in a custom way, it can fail.

Commits
-------

72684b0 [Validator] Fix ValidValidator group cascading usage
  • Loading branch information
xabbuh committed Oct 7, 2019
2 parents 718fb38 + 72684b0 commit 7432601
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -33,6 +33,6 @@ public function validate($value, Constraint $constraint)
$this->context
->getValidator()
->inContext($this->context)
->validate($value, null, [$this->context->getGroup()]);
->validate($value, null, $this->context->getGroup());
}
}

0 comments on commit 7432601

Please sign in to comment.