import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsOptional } from "class-validator";
import { Op } from "sequelize";
import { toBoolean } from "src/common/cast";
import { QueryDto } from "src/common/dto/query.dto";

export class RoleQueryDto extends QueryDto {
  @ApiProperty({ required: false })
  @IsOptional()
  @Transform(({ value }) => ({ [Op.iLike]: `%${value}%` }))
  name: string;

  @ApiProperty({ required: false })
  @Transform(({ value }) => toBoolean(value))
  @IsOptional()
  active?: boolean;
}
