From 0bb178ed1087aaf44fbab1a20795b5c94ae93e84 Mon Sep 17 00:00:00 2001 From: ZaydSkaff Date: Tue, 8 Jul 2025 14:50:00 +0300 Subject: [PATCH] make point nullable (#457) --- .../booking/entities/bookable-space.entity.ts | 4 ++-- src/booking/dtos/bookable-space-response.dto.ts | 3 ++- src/booking/dtos/create-bookable-space.dto.ts | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libs/common/src/modules/booking/entities/bookable-space.entity.ts b/libs/common/src/modules/booking/entities/bookable-space.entity.ts index 8e53cba..d7ad3ec 100644 --- a/libs/common/src/modules/booking/entities/bookable-space.entity.ts +++ b/libs/common/src/modules/booking/entities/bookable-space.entity.ts @@ -40,8 +40,8 @@ export class BookableSpaceEntity extends AbstractEntity { @Column({ type: Boolean, default: true }) active: boolean; - @Column({ type: 'int' }) - points: number; + @Column({ type: 'int', default: null }) + points?: number; @CreateDateColumn() createdAt: Date; diff --git a/src/booking/dtos/bookable-space-response.dto.ts b/src/booking/dtos/bookable-space-response.dto.ts index b637b69..3e89bd2 100644 --- a/src/booking/dtos/bookable-space-response.dto.ts +++ b/src/booking/dtos/bookable-space-response.dto.ts @@ -27,9 +27,10 @@ export class BookableSpaceConfigResponseDto { @ApiProperty({ type: Number, + nullable: true, }) @Expose() - points: number; + points?: number; } export class BookableSpaceResponseDto { diff --git a/src/booking/dtos/create-bookable-space.dto.ts b/src/booking/dtos/create-bookable-space.dto.ts index df40ee8..f7389f1 100644 --- a/src/booking/dtos/create-bookable-space.dto.ts +++ b/src/booking/dtos/create-bookable-space.dto.ts @@ -1,16 +1,17 @@ import { DaysEnum } from '@app/common/constants/days.enum'; import { ApiProperty } from '@nestjs/swagger'; import { + ArrayMinSize, IsArray, IsEnum, + IsInt, IsNotEmpty, + IsOptional, IsString, IsUUID, - IsInt, - ArrayMinSize, + Matches, Max, Min, - Matches, } from 'class-validator'; export class CreateBookableSpaceDto { @@ -53,9 +54,10 @@ export class CreateBookableSpaceDto { }) endTime: string; - @ApiProperty({ example: 10 }) + @ApiProperty({ example: 10, required: false }) + @IsOptional() @IsInt() @Min(0, { message: 'Points cannot be negative' }) @Max(1000, { message: 'Points cannot exceed 1000' }) - points: number; + points?: number; }