import { IsString, Matches, MinLength, IsOptional, IsUrl, IsEmail } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateDepartmentDto {
  @ApiProperty({
    description: 'Department code (uppercase letters, numbers, and underscores only)',
    example: 'DEPT_001',
    pattern: '^[A-Z0-9_]+$',
  })
  @IsString()
  @Matches(/^[A-Z0-9_]+$/, {
    message: 'Department code must contain only uppercase letters, numbers, and underscores',
  })
  @MinLength(3, { message: 'Department code must be at least 3 characters long' })
  code: string;

  @ApiProperty({
    description: 'Department name',
    example: 'Finance Department',
  })
  @IsString()
  @MinLength(3, { message: 'Department name must be at least 3 characters long' })
  name: string;

  @ApiProperty({
    description: 'Department description',
    example: 'Handles financial operations and compliance',
    required: false,
  })
  @IsOptional()
  @IsString()
  description?: string;

  @ApiProperty({
    description: 'Contact email for the department',
    example: 'contact@department.gov.in',
    required: false,
  })
  @IsOptional()
  @IsEmail()
  contactEmail?: string;

  @ApiProperty({
    description: 'Contact phone number',
    example: '+91-11-XXXXXXXX',
    required: false,
  })
  @IsOptional()
  @IsString()
  contactPhone?: string;

  @ApiProperty({
    description: 'Webhook URL for credential issuance events',
    example: 'https://api.department.gov.in/webhooks/credentials',
    required: false,
  })
  @IsOptional()
  @IsUrl()
  webhookUrl?: string;
}
