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
43
44
45
<?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\Optional;
use Symfony\Component\Validator\Constraints\Type;
class UsersRequest extends BaseRequest
{
#[Type('integer')]
#[NotBlank]
public $id;
#[Type('array')]
#[All(
constraints: new Collection(fields: [
'id' => [
new Type('integer'),
new NotBlank(),
],
'name' => [
new Type('string'),
new NotBlank(),
],
'age' => new Optional([
new Type('integer'),
])
])
)]
public $users;
/**
* @return array
*/
public function serialise(): array
{
return [
'id' => $this->id,
'users' => $this->users,
];
}
}