import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsEnum, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString, Length, Matches, Max, Min, ValidateIf, } from 'class-validator'; import { FanavaranInsuranceLineId } from '../fanavaran/fanavaran.types'; export class SubmitThirdPartyClaimDto { @ApiProperty({ example: '0059132574', description: 'Policy holder national code (10 digits)' }) @IsString() @IsNotEmpty() @Length(10, 10) @Matches(/^\d{10}$/, { message: 'nationalCode must be exactly 10 digits' }) nationalCode!: string; @ApiPropertyOptional({ example: FanavaranInsuranceLineId.THIRD_PARTY, enum: FanavaranInsuranceLineId, default: FanavaranInsuranceLineId.THIRD_PARTY, }) @IsOptional() @IsEnum(FanavaranInsuranceLineId) @Type(() => Number) insuranceLineId?: FanavaranInsuranceLineId; @ApiPropertyOptional({ description: 'Override ClaimExpertId instead of resolving from evaluation history', example: 4662, }) @IsOptional() @IsInt() @Type(() => Number) claimExpertId?: number; @ApiPropertyOptional({ description: 'Evaluation/claim case id — latest expert from history is used when claimExpertId is omitted', example: 'CASE-2026-001', }) @IsOptional() @IsString() evaluationRequestId?: string; @ApiPropertyOptional({ description: 'Use a specific policy id instead of resolving the latest policy from Fanavaran', example: 14821240, }) @IsOptional() @IsInt() @Type(() => Number) policyId?: number; @ApiProperty({ example: 701 }) @IsInt() @Type(() => Number) AccidentCityId!: number; @ApiProperty({ example: 155 }) @IsInt() @Type(() => Number) AccidentReportTypeId!: number; @ApiProperty({ example: 1 }) @IsInt() @Type(() => Number) AccidentVehicleUsedId!: number; @ApiProperty({ example: 167 }) @IsInt() @Type(() => Number) CompensationReferenceId!: number; @ApiProperty({ example: 2 }) @IsInt() @Type(() => Number) CulpritLicenceTypeId!: number; @ApiProperty({ example: 337 }) @IsInt() @Type(() => Number) CulpritTypeId!: number; @ApiProperty({ example: 6 }) @IsInt() @Type(() => Number) AccidentCauseId!: number; @ApiProperty({ example: '1405/03/17' }) @IsString() @IsNotEmpty() AccidentDate!: string; @ApiProperty({ example: '1405/03/17' }) @IsString() @IsNotEmpty() AnnouncementDate!: string; @ApiProperty({ example: '1405/03/17' }) @IsString() @IsNotEmpty() DocReceivedDate!: string; @ApiProperty({ example: '15:59' }) @IsString() @IsNotEmpty() AccidentTime!: string; @ApiProperty({ example: 'تهران، محله کوی نصر، بزرگراه جلال آل احمد' }) @IsString() @IsNotEmpty() AccidentLocationAddress!: string; @ApiProperty({ example: 143 }) @IsNumber() @Min(0) @Type(() => Number) EstimateAmount!: number; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) AccidentCulpritId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() CouponNo?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() CourtArchiveNo?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) CulpritLicenceCityId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) CulpritLicenceCountryId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() CulpritLicenceForeignCityName?: string | null; @ApiProperty({ example: '1394/10/13' }) @IsString() @IsNotEmpty() CulpritLicenceIssuDate!: string; @ApiProperty({ example: '1124242' }) @IsString() @IsNotEmpty() CulpritLicenceNo!: string; @ApiProperty({ example: 1 }) @IsInt() @Min(1) @Type(() => Number) DamagedCount!: number; @ApiPropertyOptional({ nullable: true }) @IsOptional() DmgAssessorFirstCreationTime?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() EntryDate?: string | null; @ApiProperty({ example: 1 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) IsLicenseMatchWithVehicleKind!: number; @ApiProperty({ example: 0 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) HasOtherCulprit!: number; @ApiProperty({ example: 0 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) IsAccidentOutOfBorder!: number; @ApiProperty({ example: 0 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) IsFatalAccident!: number; @ApiProperty({ example: 0 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) IsPlaqueChanged!: number; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueCityId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueKindId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueLeftNo?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueMiddleCodeId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() PlaqueNo?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueRightNo?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueSampleId?: number | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) PlaqueSerial?: number | null; @ApiProperty({ example: 1 }) @IsInt() @Type(() => Number) PoliceOfficerId!: number; @ApiPropertyOptional({ nullable: true }) @IsOptional() PoliceReportDesc?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() PoliceReportSeri?: string | null; @ApiPropertyOptional({ nullable: true }) @IsOptional() PoliceReportSerial?: string | null; @ApiPropertyOptional({ example: '', default: '' }) @IsOptional() @IsString() PreviousPolicyEndDate?: string; @ApiPropertyOptional({ nullable: true }) @IsOptional() TrackingCode?: string | null; @ApiProperty({ example: 0 }) @IsInt() @Min(0) @Max(1) @Type(() => Number) IsLicenseReplacement!: number; @ApiPropertyOptional({ nullable: true }) @IsOptional() @ValidateIf((_obj, value) => value !== null) @IsInt() @Type(() => Number) UnknownCulpritCauseId?: number | null; }