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] Choices constraint improvement#29658

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:masterfromnikophil:validator-choice-constant
Jan 2, 2019
Merged

[Validator] Choices constraint improvement#29658

fabpot merged 1 commit intosymfony:masterfromnikophil:validator-choice-constant
Jan 2, 2019

Conversation

@nikophil
Copy link
Contributor

@nikophilnikophil commentedDec 20, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
LicenseMIT

Hi,

here is a little improvement for the choice constraint: expose a newchoices wildcard for the messages, in order to provide a way to display easily the valid choices to the user.

thanks.

@HeahDude
Copy link
Contributor

HeahDude commentedDec 20, 2018
edited
Loading

This can be closed as this feature is supported by the annotation reader already, just remove the quotes :).

/**     * @var string     *     * @Assert\Choice(choices=App\Constants::AVAILABLE_STATES)     */private$state;
yceruto, Koc, and ogizanagi reacted with thumbs up emoji

@yceruto
Copy link
Member

@HeahDude Do you meant@Assert\Choice(choices=App\Constants::AVAILABLE_STATES)?

HeahDude and OskarStark reacted with thumbs up emoji

@HeahDude
Copy link
Contributor

yes x).

}elseif (!\in_array($value,$choices,true)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}',$this->formatValue($value))
->setParameter('{{ choices }}',implode(',',$choices))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this line is still a nice addition indeed!

@nikophil
Copy link
ContributorAuthor

yeah indeed, you're right, and i 've learnt something new :)
will we keep the new wildcardchoices i've added, or should i close the PR ?

HeahDude reacted with hooray emoji

@HeahDude
Copy link
Contributor

I'm 👍 for supporting a default choices implode, as long as we don't change the default message for both BC and let it opt-in performance wise.

@nikophil
Copy link
ContributorAuthor

i've updated the PR

}elseif (!\in_array($value,$choices,true)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}',$this->formatValue($value))
->setParameter('{{ choices }}',implode(',',$choices))
Copy link
Contributor

Choose a reason for hiding this comment

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

should also be added to the multiple=true case

choices can be any value, i think we need to map all choices usingformatValue() also.

HeahDude reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yep, you're totally right - i've added to the multiple=true case and formatted the value

@nicolas-grekasnicolas-grekas added this to thenext milestoneDec 24, 2018
@xabbuh
Copy link
Member

@nikophil Can you please update the PR title and description to match the recent changes (they will be part of the git history)?

@nikophil
Copy link
ContributorAuthor

done 👍

@fabpot
Copy link
Member

Thank you@nikophil.

@fabpotfabpot merged commit71dfa35 intosymfony:masterJan 2, 2019
fabpot added a commit that referenced this pull requestJan 2, 2019
This PR was merged into the 4.3-dev branch.Discussion----------[Validator] Choices constraint improvement| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| License       | MITHi,here is a little improvement for the choice constraint:  expose a new `choices` wildcard for the messages, in order to provide a way to display easily the valid choices to the user.thanks.Commits-------71dfa35 add new `choices` wildcard in message
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestJan 3, 2019
…int (nikophil)This PR was submitted for the 3.4 branch but it was merged into the master branch instead (closes#10836).Discussion----------document "choices" wildcard in Choice validation constraintHello,here is a little doc update in order to document the `choices` wildcard introduced bysymfony/symfony#29658Commits-------7764519 document "choices" wildcard in Choice validation constraint
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestMar 7, 2019
…ation (nikophil)This PR was squashed before being merged into the 3.4 branch (closes#10810).Discussion----------[Validator] Explained how to use array constant in annotationHi,few days ago i tried to add a new feature to the `choice` validator constraint, by adding a new `choicesFromConstant` option.symfony/symfony#29658But then, i realized this was already supported.I think this should be documented, as i think a lot of people don't know this feature.thanks.Commits-------7774aab [Validator] Explained how to use array constant in annotation
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
przemyslaw-bogusz added a commit to przemyslaw-bogusz/symfony-docs that referenced this pull requestFeb 8, 2020
javiereguiluz pushed a commit to przemyslaw-bogusz/symfony-docs that referenced this pull requestFeb 10, 2020
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull requestFeb 10, 2020
…s (przemyslaw-bogusz)This PR was submitted for the 5.0 branch but it was merged into the 4.4 branch instead (closes#13081).Discussion----------[Constraints][Choice] Added choices to message parametersIt was added in this PR:symfony/symfony#29658<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Commits-------3ba67f7 Added choices to message parameters
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@xabbuhxabbuhxabbuh approved these changes

+2 more reviewers

@ro0NLro0NLro0NL left review comments

@HeahDudeHeahDudeHeahDude approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

8 participants

@nikophil@HeahDude@yceruto@xabbuh@fabpot@ro0NL@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp