8000 Constraints Collection fields with key fields · Issue #52993 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Constraints Collection fields with key fields #52993
Closed
@111ypuk

Description

@111ypuk

Symfony version(s) affected

6.4

Description

With this assert

#[Assert\Collection(
    fields: [
        'fields' => [new Assert\Type(type: 'array')],
        'properties' => [new Assert\Type(type: 'array')],
        'catalog' => [new Assert\Type(type: 'array')],
    ],
)]
private array $configuration;

i got

The options "properties", "catalog" do not exist in constraint "Symfony\Component\Validator\Constraints\Collection".
Symfony\Component\Validator\Exception\InvalidOptionsException: The options "properties", "catalog" do not exist in constraint "Symfony\Component\Validator\Constraints\Collection". in /srv/exmo/book24/vendor/symfony/validator/Constraint.php:182

but if i rename 'fields' in 'fileds2', the problem will disappear.

How to reproduce

<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints as Assert;


$constraint = new Constraints\Collection(
    fields: [
        'fields' => [new Assert\Type(type: 'array')],
        'properties' => [new Assert\Type(type: 'array')],
        'catalog' => [new Assert\Type(type: 'array')],
    ]
);
$validator = new Assert\CollectionValidator();

var_dump(
    $validator->validate(
        [
            'fields' => [],
            'properties' => [],
            'catalog' => [],
        ],
        $constraint
    )
);

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0