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 { ApiProperty } from '@nestjs/swagger' |
||||
|
import { IsBoolean, IsNotEmpty, IsOptional, IsString, MaxLength, MinLength } from 'class-validator' |
||||
|
|
||||
export class CreateArticleDto { |
export class CreateArticleDto { |
||||
|
@IsString() |
||||
|
@IsNotEmpty() |
||||
|
@MinLength(5) |
||||
@ApiProperty() |
@ApiProperty() |
||||
title: string |
title: string |
||||
|
|
||||
|
@IsString() |
||||
|
@IsOptional() |
||||
|
@IsNotEmpty() |
||||
|
@MaxLength(300) |
||||
@ApiProperty({ required: false }) |
@ApiProperty({ required: false }) |
||||
description?: string |
description?: string |
||||
|
|
||||
|
@IsString() |
||||
|
@IsNotEmpty() |
||||
@ApiProperty() |
@ApiProperty() |
||||
body: string |
body: string |
||||
|
|
||||
|
@IsBoolean() |
||||
|
@IsOptional() |
||||
@ApiProperty({ required: false, default: false }) |
@ApiProperty({ required: false, default: false }) |
||||
published?: boolean = false |
published?: boolean = false |
||||
} |
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue