Description
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.