import { Expose, Transform, Type } from 'class-transformer';
import { IsDefined, IsNumber, IsOptional, Min, IsString, MaxLength } from 'class-validator';
import { ValidationClass } from './validationClass';

abstract class BaseCursorPaginableVC extends ValidationClass {
    @IsDefined()
    @Expose()
    @IsNumber()
    @Type(() => Number)
    @Min(1)
    limit!: number;
}

export class MandatoryCursorPaginableVC extends BaseCursorPaginableVC {
    @IsOptional()
    @Expose()
    @IsString()
    @MaxLength(1500)
    @Transform(({ value }) => (value ? value : null))
    cursor!: string | null;
}

export class MandatoryComposedCursorPaginableVC extends BaseCursorPaginableVC {
    @IsOptional()
    @Expose()
    @IsString()
    @MaxLength(1500)
    @Transform(({ value }) => (value ? value : null))
    cursor!: string | null;
}
