[Validator] NotBlank: add a new option to allow null values#29641
Merged
fabpot merged 1 commit intosymfony:masterfrom Jan 29, 2019
Merged
[Validator] NotBlank: add a new option to allow null values#29641fabpot merged 1 commit intosymfony:masterfrom
fabpot merged 1 commit intosymfony:masterfrom
Conversation
ro0NL
reviewed
Dec 18, 2018
ro0NL
approved these changes
Dec 18, 2018
xabbuh
reviewed
Dec 19, 2018
src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php
Outdated
Show resolved
Hide resolved
Member
|
ping @dunglas |
aea586d to
5856f27
Compare
Member
Author
|
Should be ready now |
xabbuh
approved these changes
Jan 28, 2019
Member
xabbuh
left a comment
There was a problem hiding this comment.
Can you please also add an entry to the changelog?
fabpot
approved these changes
Jan 29, 2019
913261c to
9b72462
Compare
9b72462 to
484d22a
Compare
Member
|
Thank you @dunglas. |
fabpot
added a commit
that referenced
this pull request
Jan 29, 2019
…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 <!-- see https://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 | todo This 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
Member
|
I've created symfony/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! |
Member
Author
|
Sorry about that @javiereguiluz. |
javiereguiluz
added a commit
to symfony/symfony-docs
that referenced
this pull request
Feb 1, 2019
…aviereguiluz) This PR was merged into the master branch. Discussion ---------- Document the allowNull option for NotBlank constraint This documents symfony/symfony#29641 Commits ------- ab2c4f1 Document the allowNull option for NotBlank constraint
Merged
fabpot
added a commit
that referenced
this pull request
Jul 3, 2019
…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 <!-- see https://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 of https://symfony.com/doc/current/reference/constraints/Length.html) which defaults to `true` in 4.4 but will trigger a deprecation if not set explicitly in 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
|
👍 @fabpot pls. merge this option to Symfony 3.4 🙌 |
Member
|
@typomedia New features are never added in patch releases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.