131 lines
2.4 KiB
TypeScript
131 lines
2.4 KiB
TypeScript
import {
|
|
ArrayMinSize,
|
|
IsArray,
|
|
IsBoolean,
|
|
IsDecimal,
|
|
IsEnum,
|
|
IsISO8601,
|
|
IsInt,
|
|
IsOptional,
|
|
IsUUID,
|
|
Max,
|
|
Min,
|
|
ValidateNested,
|
|
} from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
import { HasDay } from './validators/decorators/has-day.decorator';
|
|
import { IsAfterOrEqual } from './validators/decorators/is-after-or-equal.decorator';
|
|
import { ScheduleItemDto } from './schedule-item.dto';
|
|
import { WaypointDto } from './waypoint.dto';
|
|
import { HasValidPositionIndexes } from './validators/decorators/has-valid-position-indexes.decorator';
|
|
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
|
import { AlgorithmType } from '@modules/ad/core/application/types/algorithm.types';
|
|
|
|
export class MatchRequestDto {
|
|
@IsUUID()
|
|
@IsOptional()
|
|
id?: string;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
driver?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
passenger?: boolean;
|
|
|
|
@IsEnum(Frequency)
|
|
@HasDay('schedule', {
|
|
message: 'At least a day is required for a recurrent ad',
|
|
})
|
|
frequency: Frequency;
|
|
|
|
@IsISO8601({
|
|
strict: true,
|
|
strictSeparator: true,
|
|
})
|
|
fromDate: string;
|
|
|
|
@IsISO8601({
|
|
strict: true,
|
|
strictSeparator: true,
|
|
})
|
|
@IsAfterOrEqual('fromDate', {
|
|
message: 'toDate must be after or equal to fromDate',
|
|
})
|
|
toDate: string;
|
|
|
|
@Type(() => ScheduleItemDto)
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@ValidateNested({ each: true })
|
|
schedule: ScheduleItemDto[];
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
seatsProposed?: number;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
seatsRequested?: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
strict?: boolean;
|
|
|
|
@Type(() => WaypointDto)
|
|
@IsArray()
|
|
@ArrayMinSize(2)
|
|
@HasValidPositionIndexes()
|
|
@ValidateNested({ each: true })
|
|
waypoints: WaypointDto[];
|
|
|
|
@IsOptional()
|
|
@IsEnum(AlgorithmType)
|
|
algorithmType?: AlgorithmType;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
remoteness?: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
useProportion?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsDecimal()
|
|
@Min(0)
|
|
@Max(1)
|
|
proportion?: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
useAzimuth?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
@Min(0)
|
|
@Max(359)
|
|
azimuthMargin?: number;
|
|
|
|
@IsOptional()
|
|
@IsDecimal()
|
|
@Min(0)
|
|
@Max(1)
|
|
maxDetourDistanceRatio?: number;
|
|
|
|
@IsOptional()
|
|
@IsDecimal()
|
|
@Min(0)
|
|
@Max(1)
|
|
maxDetourDurationRatio?: number;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
page?: number;
|
|
|
|
@IsOptional()
|
|
@IsInt()
|
|
perPage?: number;
|
|
}
|