Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UniqueEntityValidator with multiple constraints fails if the first constraint is null #21554

Closed
@ghost

Description

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.8.17

Scenario: I'm validating an entity like this

$validator->validate($device, [
    new UniqueEntity([
        'fields' => ['accountId', 'tenantUuid'],
        'em' => $provisioningEm
    ])
]);

If accountId happens to be null, UniqueEntityValidator will now exclude it from the constraint list (since commit 1e3421d ), failing later on because $criteria[$fields[0]] is an invalid array access: fields[0] is the string "accountId", which is not in $criteria.
Reverting lines 88-94 to the version before the commit linked above fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions