targo-backend/src/modules/shifts/dtos/upsert-shift.dto.ts
Matthieu Haineault 4527b0e7f7 fix(shifts): clean
2025-10-09 15:22:34 -04:00

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;
};