src/users/dto/create-user.dto.ts
Properties |
Type : string
|
Decorators :
@ApiProperty({example: 'john@fleetcommand.com'})
|
|
Defined in src/users/dto/create-user.dto.ts:17
|
| firstName |
Type : string
|
Decorators :
@ApiProperty({example: 'John'})
|
|
Defined in src/users/dto/create-user.dto.ts:36
|
| lastName |
Type : string
|
Decorators :
@ApiProperty({example: 'Doe'})
|
|
Defined in src/users/dto/create-user.dto.ts:41
|
| Optional password |
Type : string
|
Decorators :
@ApiPropertyOptional({example: 'securePassword123', description: 'Optional. If omitted, the user receives an invite link to set their own password. Min 8 chars when provided.'})
|
|
Defined in src/users/dto/create-user.dto.ts:31
|
| Optional phone |
Type : string
|
Decorators :
@ApiPropertyOptional()
|
|
Defined in src/users/dto/create-user.dto.ts:51
|
| Optional role |
Type : UserRole
|
Decorators :
@ApiPropertyOptional({enum: UserRole})
|
|
Defined in src/users/dto/create-user.dto.ts:46
|
import {
IsEmail,
IsNotEmpty,
IsString,
MinLength,
IsOptional,
IsEnum,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
// ApiPropertyOptional already imported — used for the optional password field below.
import { UserRole } from '@prisma/client';
export class CreateUserDto {
@ApiProperty({ example: 'john@fleetcommand.com' })
@IsEmail()
@IsNotEmpty()
email: string;
// Optional. When omitted, the API generates a one-time invite link
// (7-day expiry) and returns it in the create response. The new user
// sets their own password through that link, so the admin never has
// to know or share an interim password.
@ApiPropertyOptional({
example: 'securePassword123',
description:
'Optional. If omitted, the user receives an invite link to set their own password. Min 8 chars when provided.',
})
@IsOptional()
@IsString()
@MinLength(8)
password?: string;
@ApiProperty({ example: 'John' })
@IsString()
@IsNotEmpty()
firstName: string;
@ApiProperty({ example: 'Doe' })
@IsString()
@IsNotEmpty()
lastName: string;
@ApiPropertyOptional({ enum: UserRole })
@IsOptional()
@IsEnum(UserRole)
role?: UserRole;
@ApiPropertyOptional()
@IsOptional()
@IsString()
phone?: string;
}