import { Transform, Type } from 'class-transformer'; import { IsISO8601, IsNumber, IsObject, IsOptional, IsString, IsUUID, Matches, Max, MaxLength, Min, MinLength, } from 'class-validator'; export class CreateFieldInventoryDto { @IsOptional() @IsUUID('4') clientGeneratedId?: string; @IsUUID('4') typeId!: string; @IsOptional() @IsUUID('4') parentId?: string; @IsOptional() @IsUUID('4') familyId?: string; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim().toUpperCase() : undefined) @IsString() @MaxLength(120) @Matches(/^[A-Z0-9][A-Z0-9._/-]*$/) code?: string; @Transform(({ value }) => typeof value === 'string' ? value.trim() : value) @IsString() @MinLength(1) @MaxLength(200) name!: string; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) @IsString() @MaxLength(200) commonName?: string | null; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) @IsString() @MaxLength(4000) description?: string | null; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) @IsString() @MaxLength(4000) discoveryNotes?: string | null; @IsObject() attributes!: Record; @Type(() => Number) @IsNumber({ maxDecimalPlaces: 6 }) @Min(-90) @Max(90) deviceLatitude!: number; @Type(() => Number) @IsNumber({ maxDecimalPlaces: 6 }) @Min(-180) @Max(180) deviceLongitude!: number; @IsOptional() @Type(() => Number) @IsNumber({ maxDecimalPlaces: 3 }) @Min(0) @Max(100000) deviceAccuracyM?: number; @IsISO8601({ strict: true }) deviceCapturedAt!: string; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) @IsString() @MaxLength(255) deviceLabel?: string | null; }