From e35ee78b08e6d91fc2c75846cd009ff38b65aea8 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Sat, 5 Sep 2026 17:45:13 -0300 Subject: [PATCH] F2.1: contrato de alta de Inventario en campo --- .../dto/create-field-inventory.dto.ts | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 api-v3/src/inspection-visits/dto/create-field-inventory.dto.ts diff --git a/api-v3/src/inspection-visits/dto/create-field-inventory.dto.ts b/api-v3/src/inspection-visits/dto/create-field-inventory.dto.ts new file mode 100644 index 0000000..3a0c28c --- /dev/null +++ b/api-v3/src/inspection-visits/dto/create-field-inventory.dto.ts @@ -0,0 +1,85 @@ +import { Transform, Type } from 'class-transformer'; +import { + IsISO8601, + IsNumber, + IsObject, + IsOptional, + IsString, + IsUUID, + Matches, + Max, + MaxLength, + Min, + MinLength, +} from 'class-validator'; + +export class CreateFieldInventoryDto { + @IsUUID('4') + typeId!: string; + + @IsOptional() + @IsUUID('4') + parentId?: 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; +}