40 lines
823 B
TypeScript
40 lines
823 B
TypeScript
import { Type } from "class-transformer";
|
|
import { IsBoolean, IsOptional, IsString, Matches, MaxLength, ValidateNested } from "class-validator";
|
|
|
|
export const COMMENT_MAX_LENGTH = 280;
|
|
|
|
export class ShiftPayloadDto {
|
|
|
|
@Matches(/^([01]\d|2[0-3]):([0-5]\d)$/)
|
|
start_time!: string;
|
|
|
|
@Matches(/^([01]\d|2[0-3]):([0-5]\d)$/)
|
|
end_time!: string;
|
|
|
|
@IsString()
|
|
type!: string;
|
|
|
|
@IsBoolean()
|
|
is_remote!: boolean;
|
|
|
|
@IsBoolean()
|
|
is_approved!: boolean;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(COMMENT_MAX_LENGTH)
|
|
comment?: string;
|
|
};
|
|
|
|
export class UpsertShiftDto {
|
|
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
@Type(()=> ShiftPayloadDto)
|
|
old_shift?: ShiftPayloadDto;
|
|
|
|
@IsOptional()
|
|
@ValidateNested()
|
|
@Type(()=> ShiftPayloadDto)
|
|
new_shift?: ShiftPayloadDto;
|
|
}; |