import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, MinLength } from 'class-validator';
import { UserRole } from 'common/enum/UserRole.enum';

export class UserLoginDto {
  @ApiProperty({
    description: 'The email of the user',
    example: 'example@gmail.com',
    type: String,
    required: true,
  })
  @IsEmail()
  @IsNotEmpty()
  email: string;

  @ApiProperty({
    description: 'The password of the user',
    example: 'Password123!',
    type: String,
    required: true,
  })
  @IsString()
  @MinLength(6)
  @IsNotEmpty()
  password: string;

  @ApiPropertyOptional({
    description: 'The role of the user',
    example: UserRole.USER,
    enum: UserRole,
    required: true,
  })
  @IsOptional()
  @IsEnum(UserRole)
  role: UserRole;
}
