Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Validator] NotBlank: add a new option to allow null values#29641
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas commentedJan 27, 2019
ping@dunglas |
aea586d to5856f27Comparedunglas commentedJan 27, 2019
Should be ready now |
xabbuh left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you please also add an entry to the changelog?
913261c to9b72462Comparefabpot commentedJan 29, 2019
Thank you@dunglas. |
…alues (dunglas)This PR was squashed before being merged into the 4.3-dev branch (closes#29641).Discussion----------[Validator] NotBlank: add a new option to allow null values| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets |#27876| License | MIT| Doc PR | todoThis PR adds a new option to the `@NotBlank` constraint to allow null values. As described in#27876, this is particularly useful when creating web APIs.Commits-------484d22a [Validator] NotBlank: add a new option to allow null values
javiereguiluz commentedFeb 1, 2019
I've createdsymfony/symfony-docs#10954 to document this new feature.@dunglas please always remember to create at least an issue in Symfony Docs to not forget about documenting new features. Thanks! |
dunglas commentedFeb 1, 2019
Sorry about that@javiereguiluz. |
…aviereguiluz)This PR was merged into the master branch.Discussion----------Document the allowNull option for NotBlank constraintThis documentssymfony/symfony#29641Commits-------ab2c4f1 Document the allowNull option for NotBlank constraint
…reject empty strings (ogizanagi)This PR was merged into the 4.4 branch.Discussion----------[Validator] Add a Length::$allowEmptyString option to reject empty strings| Q | A| ------------- | ---| Branch? | 4.4 <!-- see below -->| Bug fix? | no| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | yes <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | Todo (change the warning on top ofhttps://symfony.com/doc/current/reference/constraints/Length.html)which defaults to `true` in 4.4 but will trigger a deprecation if not set explicitlyin order to make the default `false` in 5.0.While it could be solved now thanks to#29641 by using both `@Length(min=1)` & `@NotBlank(allowNull=true)` constraints,as expressed in#27876 (comment) and following comments, the `@Length(min=1)` behavior doesn't match our expectations when reading it: it feels logical to invalidate empty strings, but it actually doesn't.Hence the proposal of making the behavior of rejecting empty strings the default in 5.0.In my opinion, the flag could even be removed later.Commits-------e113e7f [Validator] Add a Length::$allowEmptyString option to reject empty strings
typomedia commentedOct 11, 2019
👍@fabpot pls. merge this option to Symfony 3.4 🙌 |
xabbuh commentedOct 11, 2019
@typomedia New features are never added in patch releases. |
This PR adds a new option to the
@NotBlankconstraint to allow null values. As described in#27876, this is particularly useful when creating web APIs.