mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 07:49:39 +00:00
refactor: streamline Booking module and service by removing unused imports and consolidating space validation logic
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// dtos/bookable-space.dto.ts
|
||||
import { DaysEnum } from '@app/common/constants/days.enum';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsArray,
|
||||
IsEnum,
|
||||
@ -9,15 +8,26 @@ import {
|
||||
IsString,
|
||||
IsUUID,
|
||||
IsInt,
|
||||
ValidateNested,
|
||||
ArrayMinSize,
|
||||
ArrayMaxSize,
|
||||
Min,
|
||||
Max,
|
||||
Min,
|
||||
Matches,
|
||||
} from 'class-validator';
|
||||
|
||||
export class BookingSlotDto {
|
||||
export class CreateBookableSpaceDto {
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
isArray: true,
|
||||
example: [
|
||||
'3fa85f64-5717-4562-b3fc-2c963f66afa6',
|
||||
'4fa85f64-5717-4562-b3fc-2c963f66afa7',
|
||||
],
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayMinSize(1, { message: 'At least one space must be selected' })
|
||||
@IsUUID('all', { each: true, message: 'Invalid space UUID provided' })
|
||||
spaceUuids: string[];
|
||||
|
||||
@ApiProperty({
|
||||
enum: DaysEnum,
|
||||
isArray: true,
|
||||
@ -25,7 +35,6 @@ export class BookingSlotDto {
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayMinSize(1, { message: 'At least one day must be selected' })
|
||||
@ArrayMaxSize(7, { message: 'Cannot select more than 7 days' })
|
||||
@IsEnum(DaysEnum, { each: true, message: 'Invalid day provided' })
|
||||
daysAvailable: DaysEnum[];
|
||||
|
||||
@ -45,31 +54,9 @@ export class BookingSlotDto {
|
||||
})
|
||||
endTime: string;
|
||||
|
||||
@ApiProperty({ example: 10, minimum: 0 })
|
||||
@ApiProperty({ example: 10 })
|
||||
@IsInt()
|
||||
@Min(0, { message: 'Points cannot be negative' })
|
||||
@Max(1000, { message: 'Points cannot exceed 1000' })
|
||||
points: number;
|
||||
}
|
||||
|
||||
export class CreateBookableSpaceDto {
|
||||
@ApiProperty({
|
||||
type: 'string',
|
||||
isArray: true,
|
||||
example: [
|
||||
'3fa85f64-5717-4562-b3fc-2c963f66afa6',
|
||||
'4fa85f64-5717-4562-b3fc-2c963f66afa7',
|
||||
],
|
||||
})
|
||||
@IsArray()
|
||||
@ArrayMinSize(1, { message: 'At least one space must be selected' })
|
||||
@IsUUID('all', { each: true, message: 'Invalid space UUID provided' })
|
||||
spaceUuids: string[];
|
||||
|
||||
@ApiProperty({ type: BookingSlotDto, isArray: true })
|
||||
@IsArray()
|
||||
@ArrayMinSize(1, { message: 'At least one booking slot must be provided' })
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => BookingSlotDto)
|
||||
slots: BookingSlotDto[];
|
||||
}
|
||||
|
Reference in New Issue
Block a user