import {
  IsEmail,
  IsOptional,
  IsString,
  Matches,
  MaxLength,
  MinLength,
  ValidateNested,
} from 'class-validator';
import { Type } from 'class-transformer';
import { CreateShopDto } from './create-shop.dto';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateAdminWithShopDto {
  @ApiPropertyOptional({ example: 'admin@yourstore.com' })
  @IsOptional()
  @IsEmail()
  email?: string;

  @ApiPropertyOptional({ example: 'Pass1234' })
  @IsOptional()
  @IsString()
  @MinLength(4)
  @MaxLength(72)
  password?: string;

  @ApiProperty({ example: '+919876543210' })
  @Matches(/^\+?[1-9]\d{7,14}$/)
  phone!: string;

  @ApiProperty({ type: () => CreateShopDto })
  @ValidateNested()
  @Type(() => CreateShopDto)
  shop!: CreateShopDto;
}
