File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,36 @@ app.post(
211
211
```
212
212
213
213
A valid request must now include a token URL query. Example valid URL:
214
- ` /street/?uuid=af3996d0-0e8b-4165-ae97-fdc0823be417 `
214
+ ` /street/?token=af3996d0-0e8b-4165-ae97-fdc0823be417 `
215
+
216
+ The same kind of validation can also be performed on path parameters. Repurposing our earlier example,
217
+ we could expect the client to send us the UUID.
218
+
219
+ ``` javascript
220
+ const pathSchema = {
221
+ type: " object" ,
222
+ required: [" uuid" ],
223
+ properties: {
224
+ uuid: {
225
+ type: " string" ,
226
+ minLength: 36 ,
227
+ maxLength: 36
228
+ },
229
+ },
230
+ };
231
+
232
+ app .get (
233
+ " /address/:uuid" ,
234
+ validate ({ body: addressSchema, params: pathSchema }),
235
+ (request , response ) => {
236
+ /**
237
+ * Route handler logic to run when `request.body` and
238
+ * `request.params` have both been validated.
239
+ */
240
+ response .send ({});
241
+ }
242
+ );
243
+ ```
215
244
216
245
## Using dynamic schema
217
246
You can’t perform that action at this time.
0 commit comments