Issue Feature Under Review

#111688Allow dependency injection in validators of Symfony constraints

Alexander Schnitzler 11/30/26, 12:39 updated 11/30/26, 13:15

Description

ConstraintDecoratingValidator builds a new Symfony validator on every call with Validation::createValidatorBuilder() and without the service container. Constraint validators are therefore created with new:

  • A constraint validator of an extension cannot have constructor dependencies (a repository, a site finder, a service).
  • Symfony’s Expression constraint cannot be used, as its validator needs the expression language service.
  • The validator and its metadata are built again for each validated property.

Goal: Extbase provides one Symfony validator as a service that resolves constraint validators through the container (ContainerConstraintValidatorFactory). A class extending ConstraintValidator in an extension is a service and gets its dependencies by constructor injection. ConstraintDecoratingValidator uses this service.

Reviews 1

History 02

  1. Gerrit Code Review pushed patch set 1 for main to change 98214 status New Under Review 11/30/26, 13:04

  2. Gerrit Code Review pushed patch set 2 for main to change 98214 11/30/26, 13:15