← Валідація вхідних параметрів
feat(markdown): ::: containers and includes as CommonMark extensions
uk/docs/api/json-rpc-bundle/add_rpc_service/assertions.md
+33
−31
1
1
## Summary
2
2
3
−
<block class='floatinginfobox'>
4
−
5
−
<columns border="1" zebra="1">
6
−
<col width="40%">
7
−
3
+
::::::block class="floatinginfobox"
4
+
:::::columns border="1" zebra="1"
5
+
::::row
6
+
:::col width="40%"
8
7
**Classname**
9
−
</col>
10
−
<col>
8
+
:::
9
+
10
+
:::col
11
11
`Assertions`
12
−
</col>
13
−
</row>
14
−
<col width="40%">
12
+
:::
13
+
::::
15
14
15
+
::::row
16
+
:::col width="40%"
16
17
**Namespace**
17
−
</col>
18
−
<col>
18
+
:::
19
19
20
+
:::col
20
21
`Ufo\RpcObject\RPC`
21
−
</col>
22
−
</row>
23
−
<col width="40%">
22
+
:::
23
+
::::
24
24
25
+
::::row
26
+
:::col width="40%"
25
27
**Target**
26
−
</col>
27
−
<col>
28
+
:::
28
29
30
+
:::col
29
31
`parameter`
30
−
</col>
31
−
</columns>
32
+
:::
33
+
::::
34
+
:::::
32
35
33
−
<columns border="1" zebra="1">
34
−
<col align="center">
36
+
:::::columns border="1" zebra="1"
37
+
::::row
38
+
:::col align="center"
35
39
Constructor
36
−
</col>
37
−
</row>
38
−
<col>
40
+
:::
41
+
::::
39
42
43
+
::::row
44
+
:::col
40
45
```php
41
46
use Symfony\Component\Validator\Constraint;
42
47
54
59
// ...
55
60
}
56
61
```
57
−
58
−
</col>
59
−
</columns>
60
−
61
−
</block>
62
−
62
+
:::
63
+
::::
64
+
:::::
65
+
::::::
63
66
64
67
# Валідація вхідних параметрів
65
68
68
71
Для того, щоб скористатися цією можливістю, ви маєте додати до параметра, який хочете провалідувати, атрибут `#[RPC\Assertions]`, який являє собою контейнер-адаптер, що передає RPC серверу ваші очікування щодо вмісту параметра.
69
72
70
73
`RPC\Assertions` приймає абсолютно всі класи, що наслідують Symfony Constraint, і навіть ваші власні реалізації. [Перелік тих, що вже є в Symfony](https://symfony.com/doc/current/validation.html#supported-constraints).
71
−
72
74
73
75
```php
74
76
namespace App\Api\Procedures;