import {
  IsString,
  IsBoolean,
  IsEnum,
  IsOptional,
} from "class-validator";
import { Transform, Type } from "class-transformer";
import { ApiProperty } from "@nestjs/swagger";
import { toBoolean } from "src/common/cast";
import { ROLE_ENUM } from "./../../../common/constant";

export class UpdateRoleDto {
  @ApiProperty({ example: "admin", description: "The role name" })
  @IsOptional()
  @IsString()
  @IsEnum(ROLE_ENUM)
  name: ROLE_ENUM;

  @ApiProperty({ example: "admin", description: "The role display name" })
  @IsOptional()
  @IsString()
  displayName: string;

  @ApiProperty({
    example: true,
    description: "Set true if you want to activate this role",
    required: false,
  })
  @Transform(({ value }) => toBoolean(value))
  @IsOptional()
  @IsBoolean()
  active?: boolean;
}
