Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validation] Activate auto-mapped validation via an annotation #32070

Copy link
Copy link
@weaverryan

Description

@weaverryan
Issue body actions

Description
The new auto-mapping validation feature is activated via configuration. I think this is too obtuse, and people are wondering "Why is this field required? Where did that validation come from"?

The problem is that ALL your validation currently lives as annotations (or XML, YAML)... except that now this automatic system is activated in an entirely different location. Additionally, the auto-mapping (as nice at it is) is imperfect - and always will be - automatic things will never always get it right. For example, make:registration is broken with auto-mapping as the feature adds NotNull to the $password field, which will eventually hold the encoded password. This field should not have validation - symfony/maker-bundle#412

Additionally, an annotation would allow you to specify the validation group.

Example

/**
 * @Entity()
 * @Assert\AddAutomaticConstraints()
 */
class User
{
}

And ideally you could disable it automatic constraints on a property-by-property basis:

/**
 * @Entity()
 * @AddAutomaticConstraints()
 */
class User
{
    // ...

    /**
     * @NoAutomaticConstraints()
     */
    private $password;
}

This makes the feature a bit less useful, I admit. But my initial instinct is that this is causing a bit more pain than convenience.

Btw, an added problem is that the presence/absence of symfony/property-info makes this feature behave differently - and that's very not obvious.

bpolaszek, vudaltsov, develth, kaznovac, Pictor13 and 1 more

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.