34 lines
896 B
TypeScript
34 lines
896 B
TypeScript
import { IsEmail, IsArray, ArrayNotEmpty, ArrayUnique, IsISO8601, IsOptional, IsString, IsNumber, Min, Max, IsEnum } from "class-validator";
|
|
import { LeaveApprovalStatus, LeaveTypes } from "@prisma/client";
|
|
import { Type } from "class-transformer";
|
|
|
|
//sets wich types to use
|
|
export const REQUEST_TYPES = Object.values(LeaveTypes) as readonly LeaveTypes[];
|
|
export type RequestTypes = (typeof REQUEST_TYPES)[number];
|
|
|
|
export class LeaveRequestDto {
|
|
@IsEmail()
|
|
email!: string;
|
|
|
|
@IsArray()
|
|
@ArrayNotEmpty()
|
|
@ArrayUnique()
|
|
@IsISO8601({}, { each: true })
|
|
dates!: string[];
|
|
|
|
@IsEnum(LeaveTypes)
|
|
type!: string;
|
|
|
|
@IsString()
|
|
comment!: string;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsNumber({ maxDecimalPlaces: 2 })
|
|
@Min(0)
|
|
@Max(24)
|
|
requested_hours?: number;
|
|
|
|
@IsEnum(LeaveApprovalStatus)
|
|
approval_status?: LeaveApprovalStatus
|
|
} |