import {
  IsDate,
  IsEmail,
  IsEnum,
  IsInt,
  IsNotEmpty,
  IsNumber,
  IsString,
  Max,
  MaxLength,
  Min,
} from 'class-validator';
import { TransformDate } from '../../../shared/decorators/class-transformer/transform-date.decorator';
import { IsUsername } from '../../../shared/decorators/class-validator/is-username.decorator';
import { MaxDate } from '../../../shared/decorators/class-validator/max-date.decorator';
import { MinDate } from '../../../shared/decorators/class-validator/min-date.decorator';
import { Gender } from '../../../shared/enums/user/gender.enum';
import { IsOptional } from '../../../shared/decorators/class-validator/is-optional.decorator';
import { MatchesPersonNamesRegex } from '../../../shared/decorators/class-validator/matches-person-names-regex.decorator';

export class UpdateUserDto {
  @IsOptional()
  @IsString()
  @IsNotEmpty()
  @MaxLength(80)
  @MatchesPersonNamesRegex()
  fullName?: string;

  @IsOptional()
  @IsUsername()
  username?: string;

  @IsOptional()
  @IsString()
  @IsEmail()
  @MaxLength(60)
  email?: string;

  @IsOptional()
  @IsString()
  @IsNotEmpty()
  @MaxLength(512)
  password?: string;

  @IsOptional()
  @IsNumber()
  @Min(1)
  @Max(9999.99)
  weight?: number;

  @IsOptional()
  @IsNumber()
  @Min(0.01)
  @Max(99.99)
  height?: number;

  @IsOptional()
  @TransformDate()
  @IsDate()
  @MinDate('1900-01-01')
  @MaxDate(() => new Date())
  birthDate?: Date;

  @IsOptional()
  @IsEnum(Gender)
  gender?: Gender;

  @IsOptional()
  @IsInt()
  @Min(1)
  goalId?: number;

  @IsOptional()
  @IsInt()
  @Min(1)
  physicalActivityId?: number;
}
