import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsString, MaxLength, MinLength } from 'class-validator';
import { PasswordService } from '../password.service';

export class RegisterDto {
  @ApiProperty({ example: 'igor@exemplo.com' })
  @IsEmail({}, { message: 'e-mail inválido' })
  @MaxLength(254)
  email!: string;

  @ApiProperty({ minLength: PasswordService.MIN_LENGTH, writeOnly: true })
  @IsString()
  @MinLength(PasswordService.MIN_LENGTH, {
    message: `a senha precisa ter no mínimo ${PasswordService.MIN_LENGTH} caracteres`,
  })
  // Limite superior para não permitir payload gigante virar custo de CPU no hash.
  @MaxLength(128)
  password!: string;

  @ApiProperty({ example: 'Igor', description: 'nome exibido no ranking' })
  @IsString()
  @MinLength(2, { message: 'informe o nome que vai aparecer no ranking' })
  @MaxLength(40)
  displayName!: string;
}
