Skip to content

Make clear when the options are effectively required #12416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ohvitorino
Copy link

In the documentation related to the Count constraint is not clear that the parameters min and max are dependent on each other to determine if they are required.

This is an snipped taken from \Symfony\Component\Validator\Constraints\Count in package symfony/validator version 4.3.4 that states this dependency:

if (null === $this->min && null === $this->max) {
            throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), ['min', 'max']);
        }

@javiereguiluz javiereguiluz changed the base branch from master to 3.4 October 4, 2019 15:26
@javiereguiluz javiereguiluz force-pushed the count-parameters-are-not-required-at-the-same-time branch from 0d14a13 to 8534533 Compare October 4, 2019 15:26
javiereguiluz added a commit that referenced this pull request Oct 4, 2019
…vitorino)

This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #12416).

Discussion
----------

Make clear when the options are effectively required

In the documentation related to the `Count` constraint is not clear that the parameters `min` and `max` are dependent on each other to determine if they are required.

This is an snipped taken from `\Symfony\Component\Validator\Constraints\Count` in package `symfony/validator` version 4.3.4 that states this dependency:
```
if (null === $this->min && null === $this->max) {
            throw new MissingOptionsException(sprintf('Either option "min" or "max" must be given for constraint %s', __CLASS__), ['min', 'max']);
        }
```

Commits
-------

8534533 Make clear when the options are effectively required
@javiereguiluz javiereguiluz merged commit 8534533 into symfony:3.4 Oct 4, 2019
@javiereguiluz
Copy link
Member

Bruno, thanks for fixing this wrong doc. I wasn't aware of this behavior, so thanks for teaching me about it too.

@ohvitorino
Copy link
Author

@javiereguiluz No problem 👍 I’ve been using this validator constraint for years now and it was the first time I’ve noticed the documentation didn’t match de behaviour 🙂

javiereguiluz added a commit that referenced this pull request Oct 8, 2019
… not required simultaneously (ohvitorino)

This PR was merged into the 3.4 branch.

Discussion
----------

[Validator] Options `min` and `max` of Length constraint not required simultaneously

As for the Count validator constraint (see: #12416]) the options `min` and `max` of the Length constraint are not required simultaneously.

Commits
-------

0f22305 Make clear when the options min and max are required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants