From cdbd2c915c92027a7b3607e5a2dfcea5500af360 Mon Sep 17 00:00:00 2001 From: AdonaiJehosua Date: Mon, 4 Nov 2024 22:25:24 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D1=8E?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=20updateOffer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/offer/dto/update-offer.dto.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/shared/modules/offer/dto/update-offer.dto.ts b/src/shared/modules/offer/dto/update-offer.dto.ts index 1c54c3e..3b7de20 100644 --- a/src/shared/modules/offer/dto/update-offer.dto.ts +++ b/src/shared/modules/offer/dto/update-offer.dto.ts @@ -6,7 +6,7 @@ import { IsBoolean, IsEnum, IsInt, IsMongoId, - IsNumber, + IsNumber, IsOptional, IsString, Max, MaxLength, @@ -21,65 +21,80 @@ import {CityValidate, LocationValidate} from './city-and-location.dto.js'; import {CityAndLocationValidationMessages} from './city-and-location.messages.js'; export class UpdateOfferDto { + @IsOptional() @IsString({message: UpdateOfferValidationMessages.title.minLength}) @MinLength(10, {message: UpdateOfferValidationMessages.title.minLength}) @MaxLength(100, {message: UpdateOfferValidationMessages.title.maxLength}) public title?: string; + @IsOptional() @IsEnum(OfferType, {message: UpdateOfferValidationMessages.type.invalid}) public type?: OfferType; + @IsOptional() @IsInt({message: UpdateOfferValidationMessages.price.invalidFormat}) @Min(100, {message: UpdateOfferValidationMessages.price.minValue}) @Max(100000, {message: UpdateOfferValidationMessages.price.maxValue}) public price?: number; + @IsOptional() @Type(() => CityValidate) @ValidateNested({message: CityAndLocationValidationMessages.city.invalid}) public city?: City; + @IsOptional() @Type(() => LocationValidate) @ValidateNested({message: CityAndLocationValidationMessages.location.invalid}) public location?: Location; + @IsOptional() @IsBoolean({message: UpdateOfferValidationMessages.isFavorite.invalidFormat}) public isFavorite?: boolean; + @IsOptional() @IsBoolean({message: UpdateOfferValidationMessages.isPremium.invalidFormat}) public isPremium?: boolean; + @IsOptional() @IsNumber({maxDecimalPlaces: 1}, {message: UpdateOfferValidationMessages.rating.invalidFormat}) @Min(1, {message: UpdateOfferValidationMessages.price.minValue}) @Max(5, {message: UpdateOfferValidationMessages.price.maxValue}) public rating?: number; + @IsOptional() @IsString({message: UpdateOfferValidationMessages.description.invalidFormat}) @MinLength(20, {message: UpdateOfferValidationMessages.description.minLength}) @MaxLength(1024, {message: UpdateOfferValidationMessages.description.maxLength}) public description?: string; + @IsOptional() @IsArray({message: UpdateOfferValidationMessages.images.invalid}) @ArrayMinSize(6, {message: UpdateOfferValidationMessages.images.length}) @ArrayMaxSize(6, {message: UpdateOfferValidationMessages.images.length}) @IsString({each: true, message: UpdateOfferValidationMessages.images.invalidItem}) public images?: string[]; + @IsOptional() @IsString({message: UpdateOfferValidationMessages.image.invalidFormat}) public previewImage?: string; + @IsOptional() @IsArray({message: UpdateOfferValidationMessages.offerGood.invalid}) @IsEnum(OfferGood, {each: true, message: UpdateOfferValidationMessages.offerGood.invalidType}) @ArrayUnique({message: UpdateOfferValidationMessages.offerGood.unique}) public goods?: OfferGood[]; + @IsOptional() @IsMongoId({message: UpdateOfferValidationMessages.hostId.invalidId}) public hostId?: string; + @IsOptional() @IsInt({message: UpdateOfferValidationMessages.bedrooms.invalidFormat}) @Min(1, {message: UpdateOfferValidationMessages.bedrooms.minValue}) @Max(8, {message: UpdateOfferValidationMessages.bedrooms.maxValue}) public bedrooms?: number; + @IsOptional() @IsInt({message: UpdateOfferValidationMessages.maxAdults.invalidFormat}) @Min(1, {message: UpdateOfferValidationMessages.maxAdults.minValue}) @Max(10, {message: UpdateOfferValidationMessages.maxAdults.maxValue})