Category: symfony-validator

Symfony2: How can I mock a custom constraint with DI in unit test FormType?

I’m writing unit test for Symfony FormType. By following the article https://symfony.com/doc/2.8/form/unit_testing.html, everything worked very smoothly until I added a custom constraint and that constraint’s Validator had a constructor with an argument, then an error was thrown as below: [ArgumentCountError]…

How to use normalizer option in Symfony constraints component

The documentation https://symfony.com/doc/4.4/reference/constraints/Length.html#normalizer states that This option allows to define the PHP callable applied to the given value before checking if it is valid. For example, you may want to pass the ‘trim’ string to apply the trim PHP function…

Symfony "fos_rest.request_body" converter: do not deserialize nested DTO classes

I have a OrderDto class with a nested PointDto class (array of points): class OrderDto { /** * @var PointDto[] * @AssertAll({ * @AssertType(“AppDtoPointDto”) * }) * @AssertValid() */ private array $points; // getters, setters } The PointDto class also…