Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Requests;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Type;
use Symfony\Contracts\Service\Attribute\Required;
class PricesRequest extends BaseRequest
{
#[Type('array')]
#[NotBlank()]
#[Required()]
#[All(
constraints: [
new Collection(
fields: [
'price' => [
new NotBlank(),
new Type('integer'),
],
'count' => [
new NotBlank(),
new Type('integer'),
],
],
)
]
)]
public $prices;
/**
* серализация реквеста под массив
* @return mixed
*/
public function serialise(): mixed
{
return $this->prices;
}
}