From 8b4cc99e5319f8c971c20037b426a9d8a378ead6 Mon Sep 17 00:00:00 2001 From: enlineawork Date: Mon, 7 Sep 2026 21:12:57 -0300 Subject: [PATCH] F4: add inventory function DTOs --- .../dto/inventory-function.dto.ts | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 api-v3/src/asset-master/dto/inventory-function.dto.ts diff --git a/api-v3/src/asset-master/dto/inventory-function.dto.ts b/api-v3/src/asset-master/dto/inventory-function.dto.ts new file mode 100644 index 0000000..b47e34a --- /dev/null +++ b/api-v3/src/asset-master/dto/inventory-function.dto.ts @@ -0,0 +1,79 @@ +import { Transform } from 'class-transformer'; +import { + IsBoolean, + IsISO8601, + IsInt, + IsOptional, + IsString, + IsUUID, + Max, + MaxLength, + Min, + MinLength, +} from 'class-validator'; + +export class CreateInventoryFunctionDto { + @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase().replace(/[^A-Z0-9]+/g, '_').replace(/^_+|_+$/g, '') : value) + @IsString() + @MinLength(2) + @MaxLength(120) + code!: string; + + @Transform(({ value }) => typeof value === 'string' ? value.trim() : value) + @IsString() + @MinLength(2) + @MaxLength(240) + name!: string; + + @IsOptional() + @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) + @IsString() + @MaxLength(4000) + description?: string | null; + + @IsOptional() + @IsInt() + @Min(0) + @Max(100000) + sortOrder?: number; +} + +export class UpdateInventoryFunctionDto { + @IsOptional() + @Transform(({ value }) => typeof value === 'string' ? value.trim() : value) + @IsString() + @MinLength(2) + @MaxLength(240) + name?: string; + + @IsOptional() + @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) + @IsString() + @MaxLength(4000) + description?: string | null; + + @IsOptional() + @IsBoolean() + isActive?: boolean; + + @IsOptional() + @IsInt() + @Min(0) + @Max(100000) + sortOrder?: number; +} + +export class ChangeInventoryFunctionDto { + @IsUUID('4') + functionId!: string; + + @IsOptional() + @IsISO8601({ strict: true }) + effectiveAt?: string; + + @IsOptional() + @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null) + @IsString() + @MaxLength(4000) + reason?: string | null; +}