File

src/users/dto/create-user.dto.ts

Index

Properties

Properties

email
Type : string
Decorators :
@ApiProperty({example: 'john@fleetcommand.com'})
@IsEmail()
@IsNotEmpty()
firstName
Type : string
Decorators :
@ApiProperty({example: 'John'})
@IsString()
@IsNotEmpty()
lastName
Type : string
Decorators :
@ApiProperty({example: 'Doe'})
@IsString()
@IsNotEmpty()
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.'})
@IsOptional()
@IsString()
@MinLength(8)
Optional phone
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
Optional role
Type : UserRole
Decorators :
@ApiPropertyOptional({enum: UserRole})
@IsOptional()
@IsEnum(UserRole)
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;
}

results matching ""

    No results matching ""