matcher/old/modules/ad/domain/dtos/create-ad.request.ts

141 lines
2.1 KiB
TypeScript
Raw Normal View History

import { AutoMap } from '@automapper/classes';
2023-04-26 10:10:22 +00:00
import {
ArrayMinSize,
IsArray,
IsBoolean,
2023-05-11 15:47:55 +00:00
IsDate,
2023-04-26 10:10:22 +00:00
IsEnum,
2023-05-11 15:47:55 +00:00
IsMilitaryTime,
2023-04-26 10:10:22 +00:00
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
} from 'class-validator';
import { Frequency } from '../types/frequency.enum';
2023-05-22 09:25:09 +00:00
import { Coordinate } from '../../../geography/domain/entities/coordinate';
2023-05-11 15:47:55 +00:00
import { Type } from 'class-transformer';
2023-05-12 14:23:42 +00:00
import { HasTruthyWith } from './has-truthy-with.validator';
export class CreateAdRequest {
@IsString()
@IsNotEmpty()
@AutoMap()
uuid: string;
2023-05-11 15:47:55 +00:00
@IsString()
@IsNotEmpty()
@AutoMap()
userUuid: string;
2023-05-12 14:23:42 +00:00
@HasTruthyWith('passenger', {
message: 'A role (driver or passenger) must be set to true',
})
@IsBoolean()
@AutoMap()
driver: boolean;
@IsBoolean()
@AutoMap()
passenger: boolean;
2023-04-26 10:10:22 +00:00
@IsEnum(Frequency)
@AutoMap()
2023-04-26 10:10:22 +00:00
frequency: Frequency;
2023-05-11 15:47:55 +00:00
@Type(() => Date)
@IsDate()
@AutoMap()
2023-05-11 15:47:55 +00:00
fromDate: Date;
2023-05-11 15:47:55 +00:00
@Type(() => Date)
@IsDate()
@AutoMap()
2023-05-11 15:47:55 +00:00
toDate: Date;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
monTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
tueTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
wedTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
thuTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
friTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
satTime?: string;
2023-04-26 10:10:22 +00:00
@IsOptional()
2023-05-11 15:47:55 +00:00
@IsMilitaryTime()
@AutoMap()
2023-05-11 15:47:55 +00:00
sunTime?: string;
@IsNumber()
@AutoMap()
monMargin: number;
@IsNumber()
@AutoMap()
tueMargin: number;
@IsNumber()
@AutoMap()
wedMargin: number;
@IsNumber()
@AutoMap()
thuMargin: number;
@IsNumber()
@AutoMap()
friMargin: number;
@IsNumber()
@AutoMap()
satMargin: number;
@IsNumber()
@AutoMap()
sunMargin: number;
2023-05-22 09:25:09 +00:00
@Type(() => Coordinate)
2023-04-26 10:10:22 +00:00
@IsArray()
@ArrayMinSize(2)
2023-05-22 09:25:09 +00:00
@AutoMap(() => [Coordinate])
2023-08-16 10:28:20 +00:00
addresses: Coordinate[];
@IsNumber()
@AutoMap()
seatsDriver: number;
@IsNumber()
@AutoMap()
seatsPassenger: number;
2023-04-26 10:10:22 +00:00
@IsOptional()
@IsNumber()
@AutoMap()
2023-05-02 15:26:04 +00:00
seatsUsed?: number;
2023-05-11 15:47:55 +00:00
@IsBoolean()
@AutoMap()
2023-05-11 15:47:55 +00:00
strict: boolean;
}