Browse Source
Part 2: Building a REST API with NestJS and Prisma: Input Validation & Transformation
master
Part 2: Building a REST API with NestJS and Prisma: Input Validation & Transformation
master
5 changed files with 53 additions and 7 deletions
-
2package.json
-
14src/articles/articles.controller.ts
-
12src/articles/dto/create-article.dto.ts
-
3src/main.ts
-
29yarn.lock
@ -1,15 +1,27 @@ |
|||
import { ApiProperty } from '@nestjs/swagger' |
|||
import { IsBoolean, IsNotEmpty, IsOptional, IsString, MaxLength, MinLength } from 'class-validator' |
|||
|
|||
export class CreateArticleDto { |
|||
@IsString() |
|||
@IsNotEmpty() |
|||
@MinLength(5) |
|||
@ApiProperty() |
|||
title: string |
|||
|
|||
@IsString() |
|||
@IsOptional() |
|||
@IsNotEmpty() |
|||
@MaxLength(300) |
|||
@ApiProperty({ required: false }) |
|||
description?: string |
|||
|
|||
@IsString() |
|||
@IsNotEmpty() |
|||
@ApiProperty() |
|||
body: string |
|||
|
|||
@IsBoolean() |
|||
@IsOptional() |
|||
@ApiProperty({ required: false, default: false }) |
|||
published?: boolean = false |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue