transform string to number
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-02 09:52:54 +03:30
parent d039fe0b72
commit fc4740f1c1
2 changed files with 13 additions and 7 deletions
+6 -1
View File
@@ -26,7 +26,12 @@ async function bootstrap() {
await app.register(fastifyCookie); await app.register(fastifyCookie);
await app.register(multipart); await app.register(multipart);
app.useGlobalPipes(new ValidationPipe()); app.useGlobalPipes(
new ValidationPipe({
transform: true,
whitelist: true,
}),
);
app.useGlobalInterceptors( app.useGlobalInterceptors(
new ResponseInterceptor(), new ResponseInterceptor(),
@@ -3,6 +3,7 @@ import {
ArrayMinSize, ArrayMinSize,
IsArray, IsArray,
IsBoolean, IsBoolean,
IsDefined,
IsEnum, IsEnum,
IsInt, IsInt,
IsNotEmpty, IsNotEmpty,
@@ -118,12 +119,12 @@ export class CreateProductDto {
@ApiPropertyOptional({ example: 1 }) @ApiPropertyOptional({ example: 1 })
order?: number; order?: number;
@IsOptional() @IsDefined()
@IsNumber({ maxDecimalPlaces: 3 }) @IsNumber({ maxDecimalPlaces: 3 })
@Min(0.001) @Min(0.001)
@Type(() => Number) @Type(() => Number)
@ApiPropertyOptional({ description: 'Maximum quantity per order; omit or null for unlimited', example: 5 }) @ApiProperty({ description: 'Maximum quantity per order', example: 5 })
maxPurchaseQuantity?: number | null; maxPurchaseQuantity: number;
@IsOptional() @IsOptional()
@IsNumber({ maxDecimalPlaces: 3 }) @IsNumber({ maxDecimalPlaces: 3 })
@@ -142,11 +143,11 @@ export class CreateProductDto {
@ApiPropertyOptional({ example: PurchaseUnit.NUMBER }) @ApiPropertyOptional({ example: PurchaseUnit.NUMBER })
purchaseUnit?: PurchaseUnit; purchaseUnit?: PurchaseUnit;
@IsOptional() @IsDefined()
@IsNumber({ maxDecimalPlaces: 3 }) @IsNumber({ maxDecimalPlaces: 3 })
@Min(0.001) @Min(0.001)
@Type(() => Number) @Type(() => Number)
@ApiPropertyOptional({ description: 'Minimum quantity per order; omit or null for unlimited', example: 0.5 }) @ApiProperty({ description: 'Minimum quantity per order', example: 0.5 })
minPurchaseQuantity?: number | null; minPurchaseQuantity: number;
} }