F2.3: agregar DTO de hallazgo de campo

This commit is contained in:
2026-09-07 08:24:54 -03:00
parent 29c1abf907
commit 1c5efa8806
@@ -0,0 +1,58 @@
import { Transform, Type } from 'class-transformer';
import {
IsInt,
IsOptional,
IsString,
IsUUID,
Matches,
Max,
MaxLength,
Min,
MinLength,
ValidateIf,
} from 'class-validator';
const optionalText = ({ value }: { value: unknown }) =>
typeof value === 'string' && value.trim() ? value.trim() : null;
/**
* Hallazgo capturado desde la APK sobre un Inventario ya seleccionado.
* El assetId se toma de la URL para evitar inconsistencias entre pantalla y payload.
*/
export class CreateFieldFindingDto {
@IsOptional()
@Transform(optionalText)
@IsUUID('4')
catalogItemId?: string | null;
@ValidateIf((value: CreateFieldFindingDto) => !value.catalogItemId)
@Transform(optionalText)
@IsString()
@MinLength(1)
@MaxLength(500)
customTitle?: string | null;
@IsOptional()
@Transform(optionalText)
@IsString()
@MaxLength(12000)
customLegalBasis?: string | null;
@Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
@IsString()
@MinLength(1)
@MaxLength(20000)
description!: string;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(10)
severity?: number;
@IsOptional()
@Transform(optionalText)
@Matches(/^\d{4}-\d{2}-\d{2}$/)
correctionDueOn?: string | null;
}