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

[Validator] Evaluate constraint requirements when the metadata are loaded #25865

Copy link
Copy link
Closed
@xabbuh

Description

@xabbuh
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 4.1+

The Validator component comes with some constraints that require optional third-party libraries (for example, the EmailValidator constraint can optionally be used with the egulias/email-validator library). Right now, these requirements are evaluated at runtime when the validator is executed. If you do not have tests covering the validators, you may only notice at runtime that you needed to set up something when your application breaks with an exception.

To improve DX here I suggest to move these checks from the validators to the actual constraint classes to allow to catch mistakes earlier. However, we cannot do that in 4.1 as this would break applications where constraint metadata is loaded for classes that are never used (for example, when you depend on some third-party bundle that defines those constraints while you do not use all of their classes).

As an upgrade path I suggest to duplicate the checks in 4.1 from the validator classes to the constraint, but not throw exceptions there but trigger deprecations instead. So at least we can then finally make this move in 5.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)FeatureRFCRFC = Request For Comments (proposals about features that you want to be discussed)RFC = Request For Comments (proposals about features that you want to be discussed)Validator

    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.