forked from Chatbot/v3-api
31 lines
897 B
TypeScript
31 lines
897 B
TypeScript
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Transform, Type } from 'class-transformer';
|
|
import { IsBoolean, IsInt, IsOptional, IsString, Min } from 'class-validator';
|
|
|
|
export function toOptionalBoolean(value: unknown): boolean | undefined {
|
|
if (value === undefined || value === null || value === '') return undefined;
|
|
if (value === true || value === 'true' || value === '1') return true;
|
|
if (value === false || value === 'false' || value === '0') return false;
|
|
return undefined;
|
|
}
|
|
|
|
export class CursorPageQueryDto {
|
|
@ApiPropertyOptional({ default: 50 })
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
limit?: number;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
cursor?: string;
|
|
|
|
@ApiPropertyOptional({ default: false })
|
|
@IsOptional()
|
|
@Transform(({ value }) => toOptionalBoolean(value))
|
|
@IsBoolean()
|
|
include_inactive?: boolean;
|
|
}
|