import { Transform } from 'class-transformer'; import { ArrayUnique, IsArray, IsBoolean, IsEnum, IsInt, IsOptional, IsString, Max, MaxLength, Min, MinLength, } from 'class-validator'; import { AssetAttributeDataType } from '../../database/entities'; export class UpdateAttributeDefinitionDto { @IsOptional() @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value)) @IsString() @MinLength(1) @MaxLength(160) name?: string; @IsOptional() @IsEnum(AssetAttributeDataType) dataType?: AssetAttributeDataType; @IsOptional() @IsBoolean() isRequired?: boolean; @IsOptional() @IsBoolean() isActive?: boolean; @IsOptional() @Transform(({ value }) => typeof value === 'string' && value.trim() ? value.trim() : null, ) @IsString() @MaxLength(40) unit?: string | null; @IsOptional() @IsArray() @ArrayUnique() @IsString({ each: true }) @MinLength(1, { each: true }) @MaxLength(160, { each: true }) options?: string[] | null; @IsOptional() @IsInt() @Min(0) @Max(10_000) sortOrder?: number; }