import { ApiProperty } from "@nestjs/swagger"
import {
  IsEmail,
  Matches,
  ValidateIf,
  IsOptional,
  IsString,
} from "class-validator"

export class MobileLoginDto {
  // @ValidateIf((o) => !o.contact_no)
  @IsEmail({}, { message: "Invalid email format" })
  @IsOptional()
  email?: string

  @ValidateIf((o) => !!o.contact_no)
  @Matches(/^\+\d{1,4}$/, {
    message: "Invalid country code format (e.g. +91)",
  })
  @IsOptional()
  country_code?: string

  // @ValidateIf((o) => !o.email)
  @IsString()
  @IsOptional()
  contact_no?: string

  @ApiProperty({
    description: "Your Device Id",
    example: "WBE_123",
  })
  @IsString()
  device_id: string

  @ApiProperty({
    description: "API call from which device type",
    example: "android",
  })
  @IsString()
  device_type: string

  @ApiProperty({
    description: "API call from which OS version",
    example: "11.0",
  })
  @IsString()
  os_version: string

  @ApiProperty({
    description: "Role of the user",
    example: "driver",
  })
  @IsOptional()
  @IsString()
  role?: string

  @IsOptional()
  @IsString()
  device_token?: string

  @IsOptional()
  @IsString()
  access_token?: string

  @IsOptional()
  @IsString()
  fcm_token?: string
}
