import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger"; import { Transform, Type } from "class-transformer"; import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator"; import { ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, STATE_DTO, ZIP_DTO } from "../uscib-managed-sp/sp/sp-property.dto"; export class CLIENTID_DTO { @ApiProperty({ required: true }) @Max(999999999, { message: 'Property P_CLIENTID must not exceed 999999999', }) @Min(0, { message: 'Property P_CLIENTID must be at least 0 or more' }) @IsInt({ message: 'Property P_CLIENTID allows only whole numbers' }) @IsNumber({}, { message: 'Property P_CLIENTID must be a number' }) @Transform(({ value }) => Number(value)) @IsDefined({ message: 'Property P_CLIENTID is required' }) P_CLIENTID: number; } export class CLIENT_CONTACTID_DTO { @ApiProperty({ required: true }) @Max(999999999, { message: 'Property P_CLIENTCONTACTID must not exceed 999999999', }) @Min(0, { message: 'Property P_CLIENTCONTACTID must be at least 0 or more' }) @IsInt({ message: 'Property P_CLIENTCONTACTID allows only whole numbers' }) @IsNumber({}, { message: 'Property P_CLIENTCONTACTID must be a number' }) @Transform(({ value }) => Number(value)) @IsDefined({ message: 'Property P_CLIENTCONTACTID is required' }) P_CLIENTCONTACTID: number; } export class NAMEOF_DTO { @ApiProperty({ required: true }) @Length(0, 50, { message: 'Property Nameof must be between 0 to 50 characters', }) @IsString({ message: 'Property Nameof must be a string' }) @IsDefined({ message: 'Property Nameof is required' }) P_NAMEOF: string; } export class CLIENTNAME_DTO { @ApiProperty({ required: true }) // @Max(999999999, { message: "Property P_CLIENTNAME must not exceed 999999999" }) // @Min(0, { message: "Property P_CLIENTNAME must be at least 0 or more" }) // @IsInt({ message: "Property P_CLIENTNAME allows only whole numbers" }) // @IsNumber({}, { message: "Property P_CLIENTNAME must be a number" }) // @IsDefined({ message: "Property P_CLIENTNAME is required" }) @Length(0, 50, { message: 'Property P_CLIENTNAME must be between 0 to 50 characters', }) @IsString({ message: 'Property P_CLIENTNAME must be a string' }) @IsDefined({ message: 'Property P_CLIENTNAME is required' }) P_CLIENTNAME: string; } export class REVENUELOCATION_DTO { @ApiProperty({ required: true }) @Length(0, 2, { message: 'Property P_REVENUELOCATION must be between 0 to 2 characters', }) @IsString({ message: 'Property P_REVENUELOCATION must be a string' }) @IsDefined({ message: 'Property P_REVENUELOCATION is required' }) P_REVENUELOCATION: string; } export class PREPARERNAME_DTO { @ApiProperty({ required: true }) @Length(0, 50, { message: 'Property P_PREPARERNAME must be between 0 to 50 characters', }) @IsString({ message: 'Property P_PREPARERNAME must be a string' }) @IsDefined({ message: 'Property P_PREPARERNAME is required' }) P_PREPARERNAME: string; } export class STATUS_DTO { @ApiProperty({ required: true }) @Length(0, 10, { message: 'Property P_STATUS must be between 0 to 10 characters', }) @IsString({ message: 'Property P_STATUS must be a string' }) @IsDefined({ message: 'Property P_STATUS is required' }) P_STATUS: string; } export class CLIENTLOCADDRESSTABLE_ROW_DTO extends IntersectionType( NAMEOF_DTO, ADDRESS1_DTO, PartialType(ADDRESS2_DTO), CITY_DTO, STATE_DTO, ZIP_DTO, COUNTRY_DTO ) { } export class CLIENTLOCADDRESSTABLE_DTO { @ApiProperty({ required: true, type: () => [CLIENTLOCADDRESSTABLE_ROW_DTO] }) @Type(() => CLIENTLOCADDRESSTABLE_ROW_DTO) @ValidateNested({ each: true }) @IsArray({ message: 'Property P_CLIENTLOCADDRESSTABLE allows only array type', }) @IsDefined({ message: 'Property P_CLIENTLOCADDRESSTABLE is required' }) P_CLIENTLOCADDRESSTABLE: CLIENTLOCADDRESSTABLE_ROW_DTO[]; } export class CLIENTLOCATIONID_DTO { @ApiProperty({ required: true }) @Max(999999999, { message: 'Property P_CLIENTLOCATIONID must not exceed 999999999', }) @Min(0, { message: 'Property P_CLIENTLOCATIONID must be at least 0 or more' }) @IsInt({ message: 'Property P_CLIENTLOCATIONID allows only whole numbers' }) @IsNumber({}, { message: 'Property P_CLIENTLOCATIONID must be a number' }) @IsDefined({ message: 'Property P_CLIENTLOCATIONID is required' }) P_CLIENTLOCATIONID: number; } export class LOCATIONNAME_DTO { @ApiProperty({ required: true }) @Length(0, 50, { message: 'Property P_LOCATIONNAME must be between 0 to 50 characters', }) @IsString({ message: 'Property P_LOCATIONNAME must be a string' }) @IsDefined({ message: 'Property P_LOCATIONNAME is required' }) P_LOCATIONNAME: string; }