Skip to content

Commit

Permalink
fix(api): amélioration des DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Sep 4, 2023
1 parent 8bb8184 commit b46db82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/backend/src/users/dto/user-edit.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, TransformFnParams } from "class-transformer";
import { IsEmail, IsNotEmpty, MaxLength, MinLength } from "class-validator";
import {
IsEmail,
IsNotEmpty,
IsString,
MaxLength,
MinLength,
} from "class-validator";

export class UserEditDto {
@ApiProperty({
Expand All @@ -10,6 +16,7 @@ export class UserEditDto {
@MinLength(2)
@MaxLength(100)
@IsNotEmpty()
@IsString()
@Transform(({ value }: TransformFnParams) => {
return value.toString().trim();
})
Expand All @@ -22,6 +29,7 @@ export class UserEditDto {
@MinLength(2)
@MaxLength(100)
@IsNotEmpty()
@IsString()
@Transform(({ value }: TransformFnParams) => {
return value.toString().trim();
})
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/users/dto/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
IsEmail,
IsEmpty,
IsNotEmpty,
IsString,
MaxLength,
MinLength,
} from "class-validator";
Expand All @@ -13,6 +14,7 @@ export class UserDto {
@MinLength(2)
@MaxLength(100)
@IsNotEmpty()
@IsString()
@Transform(({ value }: TransformFnParams) => {
return value.toString().trim();
})
Expand All @@ -21,6 +23,7 @@ export class UserDto {
@MinLength(2)
@MaxLength(100)
@IsNotEmpty()
@IsString()
@Transform(({ value }: TransformFnParams) => {
return value.toString().trim();
})
Expand Down

0 comments on commit b46db82

Please sign in to comment.