You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,6 +205,32 @@ class UserController
205
205
}
206
206
```
207
207
208
+
### Validation Data Source
209
+
210
+
```php
211
+
use support\validation\annotation\Validate;
212
+
213
+
class UserController
214
+
{
215
+
#[Validate(
216
+
rules: ['email' => 'required|email'],
217
+
in: ['query', 'body', 'path']
218
+
)]
219
+
public function send()
220
+
{
221
+
return json(['code' => 0, 'msg' => 'ok']);
222
+
}
223
+
}
224
+
```
225
+
226
+
Use `in` to specify where validation data comes from:
227
+
228
+
***query** – HTTP query parameters from `$request->get()`
229
+
***body** – HTTP body from `$request->post()`
230
+
***path** – Path/route parameters from `$request->route->param()`
231
+
232
+
`in` can be a string or array; when it's an array, values are merged in order and later sources override earlier ones. When `in` is omitted, it defaults to the equivalent of `['query', 'body', 'path']`.
233
+
208
234
## Parameter-Level Validation (Param)
209
235
210
236
### Basic Usage
@@ -224,6 +250,23 @@ class MailController
224
250
}
225
251
```
226
252
253
+
### Validation Data Source
254
+
255
+
Parameter-level validation also supports the `in` parameter to specify data source:
0 commit comments