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] Improve constraint default option check#30737

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

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
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

Any constraint without default option used as annotation with unnamed first argument (for example,@Assert\Collection(1)) throws an exception with an ugly messageThe options "" do not exist in constraint Collection.

This PR makes constraint check the default option in the annotation case in the same way it checks it in the "real" code case. So the exception will beNo default option is configured for constraint Collection.

@vudaltsovvudaltsov changed the title[Validator] Fix constraint annotation undefined default option checking[Validator] Improve constraint default option checkMar 28, 2019
@nicolas-grekasnicolas-grekas added this to the3.4 milestoneMar 28, 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
Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

minor comment to be fixed.

@vudaltsov
Copy link
ContributorAuthor

@fabpot , done. Also fixed other messages in theConstraint class.

@fabpotfabpotforce-pushed theconstraint-annotation-undefined-default-option branch fromb04345d to915912eCompareMarch 29, 2019 17:25
@fabpot
Copy link
Member

Thank you@vudaltsov.

@fabpotfabpot merged commit915912e intosymfony:3.4Mar 29, 2019
fabpot added a commit that referenced this pull requestMar 29, 2019
…tsov)This PR was squashed before being merged into the 3.4 branch (closes#30737).Discussion----------[Validator] Improve constraint default option check| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aAny constraint without default option used as annotation with unnamed first argument (for example, `@Assert\Collection(1)`) throws an exception with an ugly message `The options "" do not exist in constraint Collection`.This PR makes constraint check the default option in the annotation case in the same way it checks it in the "real" code case. So the exception will be `No default option is configured for constraint Collection.`Commits-------915912e [Validator] Improve constraint default option check
@vudaltsovvudaltsov deleted the constraint-annotation-undefined-default-option branchApril 1, 2019 15:13
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

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@vudaltsov@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp