add custom validation pipe

This commit is contained in:
Gsk54
2022-12-23 11:00:34 +01:00
parent 4667e57f0c
commit 4e2ee28219
4 changed files with 47 additions and 5 deletions

View File

@@ -1,24 +1,29 @@
import { AutoMap } from '@automapper/classes';
import { IsString } from 'class-validator';
import { IsOptional, IsString } from 'class-validator';
export class CreateUserRequest {
@IsString()
@IsOptional()
@AutoMap()
uuid?: string;
@IsString()
@IsOptional()
@AutoMap()
firstName?: string;
@IsString()
@IsOptional()
@AutoMap()
lastName?: string;
@IsString()
@IsOptional()
@AutoMap()
email?: string;
@IsString()
@IsOptional()
@AutoMap()
phone?: string;
}

View File

@@ -1,24 +1,35 @@
import { AutoMap } from '@automapper/classes';
import { IsString } from 'class-validator';
import {
IsEmail,
IsNotEmpty,
IsOptional,
IsPhoneNumber,
IsString,
} from 'class-validator';
export class UpdateUserRequest {
@IsString()
@IsNotEmpty()
@AutoMap()
uuid: string;
@IsString()
@IsOptional()
@AutoMap()
firstName?: string;
@IsString()
@IsOptional()
@AutoMap()
lastName?: string;
@IsString()
@IsEmail()
@IsOptional()
@AutoMap()
email?: string;
@IsString()
@IsPhoneNumber()
@IsOptional()
@AutoMap()
phone?: string;
}