import { ApiProperty } from "@nestjs/swagger"
import { IsNotEmpty, IsOptional, IsString, IsNumber } from "class-validator"

export class CreateRoleDto {
  @ApiProperty({
    description: "The name of the role",
    example: "Admin",
  })
  @IsOptional()
  @IsString({ message: "Role name must be a string." })
  @IsNotEmpty({ message: "Role name cannot be empty." })
  name?: string

  @ApiProperty({
    description: "Status of the role (1 for active, 0 for inactive)",
    example: 1,
  })
  @IsOptional()
  @IsNumber({}, { message: "Status must be a number (0 or 1)." })
  status?: number

  @ApiProperty({
    description: "ID of the department associated with the role",
    example: [1, 2],
  })
  @IsNotEmpty({ message: "Department ID is required." })
  @IsOptional()
  @IsNumber({}, { each: true })
  departments?: number[]

  @ApiProperty({
    description: "ID of the business vertical associated with the role",
    example: [1, 2],
  })
  @IsNotEmpty({ message: "Business vertical ID is required." })
  @IsOptional()
  @IsNumber({}, { each: true })
  business_verticals?: number[]

  @ApiProperty({
    description: "Description of the role",
    example: "Role description",
  })
  @IsString({ message: "Description must be a string." })
  @IsOptional()
  description?: string

  @ApiProperty({
    description: "Parent role ID of the role",
    example: 1,
  })
  @IsNumber({}, { message: "Parent role ID must be a number." })
  @IsOptional()
  parent_role_id?: number

  @ApiProperty({
    description: "Is web login allowed for this role",
    example: true,
  })
  @IsOptional()
  is_web_login?: boolean
}
