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

export class CreateRoleDto {
  @ApiProperty({ example: "Admin", description: "The role name" })
  @IsDefined()
  @IsString()
  @IsEnum(ROLE_EXCEPT_SUPER_ENUM, {
    message: "Nama role harus bernilai Admin atau Patient"
  })
  name: ROLE_EXCEPT_SUPER_ENUM;

  @ApiProperty({ example: "Admin", description: "The role display name" })
  @IsDefined()
  @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;
}
