Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Validator] Validator ignores $constraints argument #28257

Closed
BoShurik opened this issue Aug 24, 2018 · 4 comments
Closed

[Validator] Validator ignores $constraints argument #28257

BoShurik opened this issue Aug 24, 2018 · 4 comments

Comments

@BoShurik
Copy link
Contributor

Symfony version(s) affected: 4.1.3

Description
When passing constraint to validate method I've got violations from annotation constrains.

How to reproduce
https://github.com/BoShurik/symfony-validator-issue

class Foo
{
    /**
     * @var Bar[]
     *
     * @Assert\Valid()
     */
    public $bars;

    public function __construct()
    {
        $this->bars = [
            new Bar(),
            new Bar(),
        ];
    }
}
$violations = $this->validator->validate($model->bars, new Count([
    'min' => 3,
    'max' => 3,
]));
/** @var ConstraintViolationInterface $violation */
foreach ($violations as $violation) {
    dump(sprintf('%s: %s', $violation->getPropertyPath(), $violation->getMessage()));
}

/*
    Got:
    ": This collection should contain exactly 3 elements."
    "[0].name: This value should not be blank." <- not expected
    "[1].name: This value should not be blank." <- not expected
 */
@BoShurik BoShurik changed the title [Validator] Validator ignores $constraints property [Validator] Validator ignores $constraints argument Aug 24, 2018
@xabbuh
Copy link
Member

xabbuh commented Aug 26, 2018

Status: Reviewed

@xabbuh
Copy link
Member

xabbuh commented Sep 24, 2018

probably related to #27090

@modiamir
Copy link

modiamir commented Jun 9, 2019

@xabbuh Does it need to be fixed?

@xabbuh
Copy link
Member

xabbuh commented Jun 9, 2019

I can no longer reproduce it. Probably fixed by #29800.

@xabbuh xabbuh closed this as completed Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants