Skip to content

[Validator] About Assert alias for constraints #19639

Closed
@gitomato

Description

@gitomato

In the documentation for validator constraints, for example NotBlank, constraints are aliased as Assert.

use Symfony\Component\Validator\Constraints as Assert;

#[Assert\NotBlank]
...

I don't really see benefits in this alias, and it adds an indirection (in the code but also in our brain). I find the non-alias version easier to read, understand and maintain.

use Symfony\Component\Validator\Constraints;

#[Constraints\NotBlank]
...

Is there any reason for suggesting adding this alias?

PS: Thanks for your hard work on Symfony!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions