Skip to content

[Validator] Required and Optional Field Constraints in YAML #62705

@ro0NL

Description

@ro0NL

Symfony version(s) affected

7

Description

Hi,

We're seeing following deprecations when testing 7.4

   * 1x: Since symfony/validator 7.3: Using constraints not supporting named arguments is deprecated. Try adding the HasNamedArguments attribute to \Symfony\Component\Validator\Constraints\Optional.
        in /app/vendor/symfony/deprecation-contracts/function.php:25
   * 1x: Since symfony/validator 7.4: Passing an array of options to configure the "Symfony\Component\Validator\Constraints\Optional" constraint is deprecated, use named arguments instead.
        in /app/vendor/symfony/deprecation-contracts/function.php:25
   * 1x: Since symfony/validator 7.4: Support for evaluating options in the base Constraint class is deprecated. Initialize properties in the constructor of Symfony\Component\Validator\Constraints\Optional instead.
        in /app/vendor/symfony/deprecation-contracts/function.php:25

But it seems they cannot be solved, as the options from yaml will always be [value => ...] or [constraints => ...] at

if (null !== $options) {
trigger_deprecation('symfony/validator', '7.4', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
}

How to reproduce

https://symfony.com/doc/current/reference/constraints/Collection.html#required-and-optional-field-constraints

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