src/drivers/dto/create-driver.dto.ts
Properties |
|
| Optional email |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/drivers/dto/create-driver.dto.ts:29
|
| firstName |
Type : string
|
Decorators :
@ApiProperty({example: 'Mike'})
|
|
Defined in src/drivers/dto/create-driver.dto.ts:17
|
| lastName |
Type : string
|
Decorators :
@ApiProperty({example: 'Johnson'})
|
|
Defined in src/drivers/dto/create-driver.dto.ts:23
|
| Optional licenseExpiry |
Type : string
|
Decorators :
@ApiPropertyOptional({example: '2027-06-30'})
|
|
Defined in src/drivers/dto/create-driver.dto.ts:61
|
|
Licence expiry. We accept any valid date and let the UI flag soon-to- expire / already-expired with a warning badge — we do NOT block past dates outright because some fleets onboard drivers whose licence just expired and is being renewed. |
| Optional licenseNumber |
Type : string
|
Decorators :
@ApiPropertyOptional({description: 'Driver's licence number'})
|
|
Defined in src/drivers/dto/create-driver.dto.ts:50
|
| Optional phone |
Type : string
|
Decorators :
@ApiPropertyOptional({example: '+254712345678'})
|
|
Defined in src/drivers/dto/create-driver.dto.ts:44
|
|
Permissive phone validation — accepts E.164 (+254712345678) or local formats with optional separators. We don't insist on E.164 because driver onboarding is typically a paper process and admins type what the licence shows. |
import {
IsNotEmpty,
IsString,
IsOptional,
IsEmail,
IsDateString,
Matches,
MaxLength,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class CreateDriverDto {
@ApiProperty({ example: 'Mike' })
@IsString()
@IsNotEmpty()
@MaxLength(60)
firstName: string;
@ApiProperty({ example: 'Johnson' })
@IsString()
@IsNotEmpty()
@MaxLength(60)
lastName: string;
@ApiPropertyOptional()
@IsOptional()
@IsEmail()
@MaxLength(120)
email?: string;
/**
* Permissive phone validation — accepts E.164 (+254712345678) or local
* formats with optional separators. We don't insist on E.164 because
* driver onboarding is typically a paper process and admins type what
* the licence shows.
*/
@ApiPropertyOptional({ example: '+254712345678' })
@IsOptional()
@IsString()
@MaxLength(30)
@Matches(/^\+?[0-9 ()\-]{7,}$/, {
message: 'phone must be 7+ digits, optionally with +, spaces, dashes, or parentheses',
})
phone?: string;
@ApiPropertyOptional({ description: "Driver's licence number" })
@IsOptional()
@IsString()
@MaxLength(40)
licenseNumber?: string;
/**
* Licence expiry. We accept any valid date and let the UI flag soon-to-
* expire / already-expired with a warning badge — we do NOT block past
* dates outright because some fleets onboard drivers whose licence
* just expired and is being renewed.
*/
@ApiPropertyOptional({ example: '2027-06-30' })
@IsOptional()
@IsDateString()
licenseExpiry?: string;
}