Files
dh-inspeccion-v2/api-v3/src/asset-master/dto/list-asset-versions-query.dto.ts
T

63 lines
1.1 KiB
TypeScript

import { Transform, Type } from 'class-transformer';
import {
IsEnum,
IsInt,
IsISO8601,
IsOptional,
IsString,
IsUUID,
Max,
MaxLength,
Min,
} from 'class-validator';
import {
AssetInformationStatus,
AssetVersionChangeType,
} from '../../database/entities';
const trim = ({ value }: { value: unknown }) =>
typeof value === 'string' ? value.trim() : value;
export class AssetVersionPageQueryDto {
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
page = 1;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(100)
pageSize = 25;
}
export class ListAssetVersionsQueryDto extends AssetVersionPageQueryDto {
@Transform(trim)
@IsOptional()
@IsString()
@MaxLength(200)
search?: string;
@IsOptional()
@IsUUID('4')
typeId?: string;
@IsOptional()
@IsEnum(AssetInformationStatus)
status?: AssetInformationStatus;
@IsOptional()
@IsEnum(AssetVersionChangeType)
changeType?: AssetVersionChangeType;
@IsOptional()
@IsISO8601({ strict: true })
from?: string;
@IsOptional()
@IsISO8601({ strict: true })
to?: string;
}