Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Validator] Fix annotation default for @Count and @Length#30736

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

Merged
fabpot merged 1 commit intosymfony:3.4fromvudaltsov:assert-length-count-default
Mar 29, 2019

Conversation

@vudaltsov
Copy link
Contributor

@vudaltsovvudaltsov commentedMar 28, 2019
edited
Loading

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Fixed ticketsn/a
LicenseMIT
Doc PRis it worth mentioning?

Count andLength constraints allow to pass the exact value as the constructor argument when used in code.

newLength(5);// is same asnewLength(['min' =>5,'max' =>5]);

At the same time when using them as annotations,@Assert\Length(5) throwsThe options "" do not exist in constraint Symfony\\Component\\Validator\\Constraints\\Length (fix for ugly exception is proposed in#30737). This happens because annotation's default value is passed asvalue. SinceLength does not have a default option,value is replaced with''.

This PR fixes this inconsistency.

Copy link
Contributor

@dmaicherdmaicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should be mentioned in the docs I think 😊

@fabpotfabpotforce-pushed theassert-length-count-default branch fromcaf40a7 to7bfb8c1CompareMarch 29, 2019 15:49
@fabpot
Copy link
Member

Thank you@vudaltsov.

OskarStark reacted with thumbs up emoji

@fabpotfabpot merged commit7bfb8c1 intosymfony:3.4Mar 29, 2019
fabpot added a commit that referenced this pull requestMar 29, 2019
…(vudaltsov)This PR was squashed before being merged into the 3.4 branch (closes#30736).Discussion----------[Validator] Fix annotation default for@count and@Length| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets | n/a| License       | MIT| Doc PR        | is it worth mentioning?`Count` and `Length` constraints allow to pass the exact value as the constructor argument when used in code.```phpnew Length(5);// is same asnew Length(['min' => 5, 'max' => 5]);```At the same time when using them as annotations, `@Assert\Length(5)` throws `The options "" do not exist in constraint Symfony\\Component\\Validator\\Constraints\\Length` (fix for ugly exception is proposed in#30737). This happens because annotation's default value is passed as `value`. Since `Length` does not have a default option, `value` is replaced with `''`.This PR fixes this inconsistency.Commits-------7bfb8c1 [Validator] Fix annotation default for@count and@Length
@vudaltsovvudaltsov deleted the assert-length-count-default branchMarch 29, 2019 15:51
This was referencedApr 2, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@OskarStarkOskarStarkOskarStark approved these changes

+1 more reviewer

@dmaicherdmaicherdmaicher approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@vudaltsov@fabpot@dmaicher@OskarStark@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp