8000 [Validation] Allow multiple `atPath()`s at callback constraint · Issue #36544 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Validation] Allow multiple atPath()s at callback constraint #36544
Closed
@ThomasLandauer

Description

@ThomasLandauer

Description
It would be handy to add the same violation to multiple form fields, if you want to display the same error message at two fields, e.g. "You need to provide either your name or your email address"

https://symfony.com/doc/current/reference/constraints/Callback.html

Example
The (for the user) easiest way would be to just repeat atPath():

$context->buildViolation('...')->atPath('name')->atPath('email')->addViolation();

Instead of having to repeat the entire violation (current status quo):

$context->buildViolation('...')->atPath('name')->addViolation();
$context->buildViolation('...')->atPath('email')->addViolation();

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