Answer the question
In order to leave comments, you need to log in
How to set validation order with validation of another field in Symfony?
Hello! There is a conditional entity with two fields:
/**
* @Assert\Range(min=1, max=self::SPEND_MAX)
*/
public ?int $spendMax = null;
/**
* @Assert\NotBlank()
* @Assert\Length(max=255)
*/
public string $name;
/**
* @Assert\NotBlank(<b>для поля name</b>)
* @Assert\Range(min=1, max=self::SPEND_MAX)
*/
public ?int $spendMax = null;
Answer the question
In order to leave comments, you need to log in
- swap the fields
OR
- create 2 groups, put the fields in them and specify the order of the groups: https://symfony.com/doc/current/validation/sequenc...
OR
- instead of annotations, use the loadValidatorMetadata PHP method and specify the required one in it order: https://symfony.com/doc/current/validation.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question