Improve validation of activities import (#2496)

* Improve validation of activities import: expects positive values for fee, quantity and unitPrice

* Update changelog

---------

Co-authored-by: Rafael Claudio <rafacla@github.com>
Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
This commit is contained in:
Rafael
2023-10-24 15:51:48 -03:00
committed by GitHub
parent fa627f686f
commit 2dcc7e161c
4 changed files with 15 additions and 4 deletions

View File

@@ -13,7 +13,9 @@ import {
IsISO8601,
IsNumber,
IsOptional,
IsString
IsPositive,
IsString,
Min
} from 'class-validator';
import { isString } from 'lodash';
@@ -48,9 +50,11 @@ export class CreateOrderDto {
date: string;
@IsNumber()
@Min(0)
fee: number;
@IsNumber()
@IsPositive()
quantity: number;
@IsString()
@@ -64,6 +68,7 @@ export class CreateOrderDto {
type: Type;
@IsNumber()
@IsPositive()
unitPrice: number;
@IsBoolean()

View File

@@ -13,7 +13,9 @@ import {
IsISO8601,
IsNumber,
IsOptional,
IsString
IsPositive,
IsString,
Min
} from 'class-validator';
import { isString } from 'lodash';
@@ -47,12 +49,14 @@ export class UpdateOrderDto {
date: string;
@IsNumber()
@Min(0)
fee: number;
@IsString()
id: string;
@IsNumber()
@IsPositive()
quantity: number;
@IsString()
@@ -66,5 +70,6 @@ export class UpdateOrderDto {
type: Type;
@IsNumber()
@IsPositive()
unitPrice: number;
}