Skip to content

Commit beb883b

Browse files
Merge pull request #2491 from carbondigitalus/patch-1
docs(pipes): Add more detail for Joi Schema reference section
2 parents 2790529 + 3ac6ca8 commit beb883b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

content/pipes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,22 @@ In this case, we want to bind the pipe at the method call level. In our current
294294
2. Pass the context-specific Joi schema in the class constructor of the pipe
295295
3. Bind the pipe to the method
296296

297+
Joi schema example:
298+
299+
```typescript
300+
const createCatSchema = Joi.object({
301+
name: Joi.string().required(),
302+
age: Joi.number().required(),
303+
breed: Joi.string().required(),
304+
})
305+
306+
export interface CreateCatDto {
307+
name: string;
308+
age: number;
309+
breed: string;
310+
}
311+
```
312+
297313
We do that using the `@UsePipes()` decorator as shown below:
298314

299315
```typescript
@@ -314,6 +330,7 @@ async create(createCatDto) {
314330

315331
> info **Hint** The `@UsePipes()` decorator is imported from the `@nestjs/common` package.
316332
333+
317334
#### Class validator
318335

319336
> warning **Warning** The techniques in this section require TypeScript, and are not available if your app is written using vanilla JavaScript.

0 commit comments

Comments
 (0)