8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I try to use the Assert\Choice inside the Assert\All, like following I receive a The choice constraint expects a valid callback error message.
Assert\Choice
Assert\All
The choice constraint expects a valid callback
// src/AppBundle/Entity/User.php namespace AppBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; class User { /** * @Assert\Count(min="1") * @Assert\All({ * @Assert\Choice(callback={"getValidColors"}) * }) */ protected $favoriteColors = array(); public static function getValidColors() { return array('red', 'green', 'blue'); } }
The error message:
To walkaround this problem, I've added the full-qualified-class-name to the first paramater of the callback option of the Assert\Choice, as follow:
// src/AppBundle/Entity/User.php namespace AppBundle\Entity; use Symfony\Component\Validator\Constraints as Assert; class User { /** * @Assert\Count(min="1") * @Assert\All({ * @Assert\Choice(callback={"AppBundle\Entity\User", "getValidColors"}) * }) */ protected $favoriteColors = array(); public static function getValidColors() { return array('red', 'green', 'blue'); } }
And this way it has worked, but this method is not covered at any documentation. I'm willing to help if I know what needs to be done.
The text was updated successfully, but these errors were encountered:
The cause of this behaviour probably basically is the same as in #20477.
Sorry, something went wrong.
bug #25529 [Validator] Fix access to root object when using composite…
d975ad6
… constraint (ostrolucky) This PR was merged into the 2.7 branch. Discussion ---------- [Validator] Fix access to root object when using composite constraint | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12315, #20477, #21706 | License | MIT | Doc PR | Commits ------- b18cdcf [Validator] Fix access to root object when using composite constraint
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
If I try to use the
Assert\Choice
inside theAssert\All
, like following I receive aThe choice constraint expects a valid callback
error message.The error message:

To walkaround this problem, I've added the full-qualified-class-name to the first paramater of the callback option of the
Assert\Choice
, as follow:And this way it has worked, but this method is not covered at any documentation. I'm willing to help if I know what needs to be done.
The text was updated successfully, but these errors were encountered: