mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 04:08:11 +00:00
@@ -1,4 +1,4 @@
|
|||||||
import { IsString, IsArray, ValidateNested, IsOptional, IsInt, IsEnum, IsDateString, MaxDate } from 'class-validator';
|
import { IsString, IsArray, ValidateNested, IsOptional, IsInt, IsEnum, IsDate, MaxDate } from 'class-validator';
|
||||||
import { Type, Transform } from 'class-transformer';
|
import { Type, Transform } from 'class-transformer';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
import { Currency, IdDocumentType } from '@prisma/client';
|
import { Currency, IdDocumentType } from '@prisma/client';
|
||||||
@@ -10,10 +10,12 @@ export class PassengerInputDto {
|
|||||||
@ApiPropertyOptional({ example: 'ret-leg2-seat-uuid', description: '**ROUND_TRIP_TRANSIT:** Return leg-2 seat ID' }) @IsOptional() @IsString() returnLeg2SeatId?: string;
|
@ApiPropertyOptional({ example: 'ret-leg2-seat-uuid', description: '**ROUND_TRIP_TRANSIT:** Return leg-2 seat ID' }) @IsOptional() @IsString() returnLeg2SeatId?: string;
|
||||||
@ApiProperty({ example: 'Abebe Kebede' }) @IsString() passengerName: string;
|
@ApiProperty({ example: 'Abebe Kebede' }) @IsString() passengerName: string;
|
||||||
@ApiProperty({ example: '1990-05-15', description: 'Date of birth (YYYY-MM-DD). Must not be a future date.' })
|
@ApiProperty({ example: '1990-05-15', description: 'Date of birth (YYYY-MM-DD). Must not be a future date.' })
|
||||||
@IsDateString()
|
// Incoming value is an ISO date string (YYYY-MM-DD); transform to a Date so
|
||||||
@Transform(({ value }) => value)
|
// @MaxDate (which requires an actual Date instance) evaluates correctly.
|
||||||
|
@Transform(({ value }) => (value ? new Date(value) : value))
|
||||||
|
@IsDate()
|
||||||
@MaxDate(() => new Date(), { message: 'Date of birth cannot be in the future' })
|
@MaxDate(() => new Date(), { message: 'Date of birth cannot be in the future' })
|
||||||
dateOfBirth: string;
|
dateOfBirth: Date;
|
||||||
@ApiProperty({ example: 'NATIONAL_ID', enum: IdDocumentType, description: 'NATIONAL_ID for Ethiopians (Verifayda verified), PASSPORT for others' }) @IsEnum(IdDocumentType) idDocumentType: IdDocumentType;
|
@ApiProperty({ example: 'NATIONAL_ID', enum: IdDocumentType, description: 'NATIONAL_ID for Ethiopians (Verifayda verified), PASSPORT for others' }) @IsEnum(IdDocumentType) idDocumentType: IdDocumentType;
|
||||||
@ApiPropertyOptional({ example: 'ET123456789', description: 'Ethiopian national ID - verified via Verifayda 2.0 (NOT stored in database)' }) @IsOptional() @IsString() idDocumentNumber?: string;
|
@ApiPropertyOptional({ example: 'ET123456789', description: 'Ethiopian national ID - verified via Verifayda 2.0 (NOT stored in database)' }) @IsOptional() @IsString() idDocumentNumber?: string;
|
||||||
@ApiPropertyOptional({ example: 'P1234567', description: 'Passport number for non-Ethiopian passengers (no verification)' }) @IsOptional() @IsString() passportNumber?: string;
|
@ApiPropertyOptional({ example: 'P1234567', description: 'Passport number for non-Ethiopian passengers (no verification)' }) @IsOptional() @IsString() passportNumber?: string;
|
||||||
@@ -44,10 +46,12 @@ export class RoundTripPassengerDto {
|
|||||||
example: '1990-05-15',
|
example: '1990-05-15',
|
||||||
description: 'Date of birth (YYYY-MM-DD). Must not be a future date.'
|
description: 'Date of birth (YYYY-MM-DD). Must not be a future date.'
|
||||||
})
|
})
|
||||||
@IsDateString()
|
// Incoming value is an ISO date string (YYYY-MM-DD); transform to a Date so
|
||||||
@Transform(({ value }) => value)
|
// @MaxDate (which requires an actual Date instance) evaluates correctly.
|
||||||
|
@Transform(({ value }) => (value ? new Date(value) : value))
|
||||||
|
@IsDate()
|
||||||
@MaxDate(() => new Date(), { message: 'Date of birth cannot be in the future' })
|
@MaxDate(() => new Date(), { message: 'Date of birth cannot be in the future' })
|
||||||
dateOfBirth: string;
|
dateOfBirth: Date;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
example: 'NATIONAL_ID',
|
example: 'NATIONAL_ID',
|
||||||
|
|||||||
Reference in New Issue
Block a user