mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
refactor: api validation schema
This commit is contained in:
55
packages/server-nest/src/modules/Branches/dtos/Branch.dto.ts
Normal file
55
packages/server-nest/src/modules/Branches/dtos/Branch.dto.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsEmail,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUrl,
|
||||
} from 'class-validator';
|
||||
|
||||
class CommandBranchDto {
|
||||
@ApiProperty({ description: 'Branch name' })
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch code' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
code?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch address' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
address?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch city' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
city?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch country' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
country?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch phone number' })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
phone_number?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch email' })
|
||||
@IsOptional()
|
||||
@IsEmail()
|
||||
@IsString()
|
||||
email?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'Branch website' })
|
||||
@IsOptional()
|
||||
@IsUrl()
|
||||
@IsString()
|
||||
website?: string;
|
||||
}
|
||||
|
||||
export class CreateBranchDto extends CommandBranchDto {}
|
||||
export class EditBranchDto extends CommandBranchDto {}
|
||||
Reference in New Issue
Block a user