feat: add validation for null values in bookingFieldsResponses (#25272)

* feat: add validation for null values in bookingFieldsResponses

- Add test case to verify 400 error when bookingFieldsResponses contains null values
- Create ValidateBookingFieldsResponses decorator to reject null values in booking field responses
- Apply validator to CreateBookingInput_2024_08_13.bookingFieldsResponses property
- Ensure all booking field response values are non-null strings

* feat: transform null values to empty strings in bookingFieldsResponses

- Remove ValidateBookingFieldsResponses validator that rejected null values
- Add Transform decorator to convert null values to empty strings in bookingFieldsResponses
- Update test to verify null values are transformed to empty strings instead of returning 400 error

* remove extra spaces

* test: add rescheduleReason null value test case

---------

Co-authored-by: Morgan <[email protected]>
This commit is contained in:
chauhan_sandMorgan authored and GitHub committed 2025-11-20 10:45:22 +00:00
1 parent 37c26793f5
commit fbfa27735b
2 files changed
+37 -8

No files matched your search

@@ -1,5 +1,5 @@
import { ApiExtraModels, ApiProperty, ApiPropertyOptional, getSchemaPath } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { Transform, Type } from "class-transformer";
import type { ValidationArguments, ValidationOptions } from "class-validator";
import {
IsInt,
@@ -239,6 +239,14 @@ export class CreateBookingInput_2024_08_13 {
})
@IsObject()
@IsOptional()
@Transform(({ value }) => {
if (!value || typeof value !== "object") return value;
const transformed: Record<string, unknown> = {};
for (const [key, val] of Object.entries(value)) {
transformed[key] = val === null ? "" : val;
}
return transformed;
})
bookingFieldsResponses?: Record<string, unknown>;
@ApiPropertyOptional({