import {
  IsEmail,
  IsNotEmpty,
  IsOptional,
  IsString,
  MinLength,
  MaxLength,
  IsIn,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateUserDto {
  @ApiProperty({ example: 'max.mustermann@xinion.de' })
  @IsEmail({}, { message: 'Bitte gültige E-Mail-Adresse angeben' })
  @IsNotEmpty()
  email!: string;

  @ApiProperty({ example: 'SicheresPasswort123!' })
  @IsString()
  @IsNotEmpty()
  @MinLength(8, { message: 'Passwort muss mindestens 8 Zeichen lang sein' })
  @MaxLength(128, { message: 'Passwort darf maximal 128 Zeichen lang sein' })
  password!: string;

  @ApiProperty({ example: 'Max' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  firstName!: string;

  @ApiProperty({ example: 'Mustermann' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  lastName!: string;

  @ApiProperty({
    example: 'USER',
    enum: ['PLATFORM_ADMIN', 'TENANT_ADMIN', 'USER'],
    required: false,
  })
  @IsOptional()
  @IsString()
  @IsIn(['PLATFORM_ADMIN', 'TENANT_ADMIN', 'USER'])
  role?: string;
}
