{
"cf_sub_products": [
{
"size": "s",
"cf_product_id": 1,
"enabled": false,
"price": 123,
"sku": "123"
},
{
"size": "l",
"cf_product_id": 1,
"enabled": true,
"price": 123,
"sku": "asd"
}
]
}
$constraint = new Assert\Collection(
[
'fields' => [
'cf_sub_products' => [
new Assert\NotBlank(),
new Assert\Type('array')
]
]
]
);
$violations = $validator->validate($body, $constraint);
$constraint = new Assert\Collection(
[
'fields' => [
'cf_sub_products' => [
new Assert\NotBlank(),
new Assert\Type('array'),
new Assert\All([
new Assert\Collection([
'fields' => [
"size" => [
new Assert\NotBlank(),
],
"cf_product_id" => [
new Assert\NotBlank(),
],
"enabled" => [
new Assert\NotBlank(),
],
"price" => [
new Assert\NotBlank(),
],
"sku" => [
new Assert\NotBlank(),
],
],
])
])
]
]
]
);
$violations = $validator->validate($body, $constraint);