I want to validate an array using validation group because of some conditions but validation group doesn't seem affect array?
$params = [
'type' => 'a',
'province' => 'b',
'district' => 'c'
];
$constraints = new Collection([
'type' => [new NotBlank()],
'province' => [new NotBlank(['groups' => ['selection']])],
'district' => [new NotBlank(['groups' => ['selection']])],
'distance' => [new NotBlank(['groups' => ['location']])],
'lat' => [new NotBlank(['groups' => ['location']])],
'lon' => [new NotBlank(['groups' => ['location']])],
]);
$errors = $this->container->get('validator')->validate($params, $constraints, ['selection']);
Validation errors:
Array[distance]:
This field is missing. (code 1)
Array[lat]:
This field is missing. (code 1)
Array[lon]:
This field is missing. (code 1)
Thank for your help!