I have issue:
* @Assert\Type(type="array")
* @Assert\Count(
* min=5,
* max=10
* )
I need validate type array and then I need validate if array have min and max count.
But when I send to value string, then Assert\Type evaluate not valid type, it is ok, then validation continue to Assert\Count and there is problem it is not string and Assert\Count throw UnexpectedValueException and I have message: This value should be of type {{ type }}. and this is not correct vaidation message for me.
Is possible do Assert\Count only when is Assert\Type condition correct?
CodePudding user response:
If i am understanding your question then using Assert Sequentially is the resolution.
Update your Asserts to look like this:
* @Assert\Sequentially({
* @Assert\Type(type="array"),
* @Assert\Count(min=5, max=10),
* })
*/
The first validation will be raised if your Type is not an array and not perform any further validations.
