Skip to content
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

Describe how empty strings affect the validation of string constraints #4244

Closed
xabbuh opened this issue Sep 17, 2014 · 5 comments
Closed

Describe how empty strings affect the validation of string constraints #4244

xabbuh opened this issue Sep 17, 2014 · 5 comments
Labels
actionable Clear and specific issues ready for anyone to take them. good first issue Ideal for your first contribution! (some Symfony experience may be required) hasPR A Pull Request has already been submitted for this issue. Validator

Comments

@xabbuh
Copy link
Member

xabbuh commented Sep 17, 2014

For example, when an empty string is validated through the Length constraint, it is considered to be valid no matter if the constraint required a minimum length (see symfony/symfony#11943). It should be made clear that you also have to use the NotBlank constraint to disallow empty strings too.

Note that the Length constraint isn't the only constraint with this behaviour.

@xabbuh xabbuh added actionable Clear and specific issues ready for anyone to take them. Validator labels Sep 17, 2014
@xabbuh
Copy link
Member Author

xabbuh commented Mar 29, 2015

This does not only affect string related validators.

Quoting from #5122:

Hello,
I tried to validate an entity with an Assert\Choice constraint and discovered that it is considered valid if you pass in a NULL value. This is really counter intuitive and I did not find any information in the validation documentation about this behavior. Only after looking at the "JSR303 Bean Validation specification" which is in the first paragraph I found out about this.

There should be some kind of warning or hint that NULL values will not be checked/considered valid.

@wouterj
Copy link
Member

wouterj commented May 2, 2015

I think we can add this in the table for each constraint in the reference.

@wouterj wouterj added the good first issue Ideal for your first contribution! (some Symfony experience may be required) label May 2, 2015
@wouterj wouterj added the hasPR A Pull Request has already been submitted for this issue. label May 23, 2015
weaverryan added a commit that referenced this issue Jun 11, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

Constraints - empty strings and null values

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |  #4244

Commits
-------

2616acd Constraints - empty strings and null values
@weaverryan
Copy link
Member

This was partially handled in #5288 (just for Length)

@javiereguiluz
Copy link
Member

If we can't come up with a list of constraints to update, we'll need to close this as "solved", ... because Length was already updated. Thanks!

@javiereguiluz javiereguiluz added hasPR A Pull Request has already been submitted for this issue. and removed Waiting feedback labels Sep 26, 2018
javiereguiluz added a commit that referenced this issue Sep 28, 2018
This PR was squashed before being merged into the 2.8 branch (closes #10407).

Discussion
----------

Added a note about the usage of NotBlank

Fixes #4244 and fixes #10357.

Commits
-------

24ed17e Added a note about the usage of NotBlank
@javiereguiluz
Copy link
Member

Fixed by #10407.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. good first issue Ideal for your first contribution! (some Symfony experience may be required) hasPR A Pull Request has already been submitted for this issue. Validator
Projects
None yet
Development

No branches or pull requests

4 participants