BUR-61 current.value сделан nullable в бд. Соответствующие сущности скорректированы под изменение бд
This commit is contained in:
11
src/common/is-nullable-number.decorator.ts
Normal file
11
src/common/is-nullable-number.decorator.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { applyDecorators } from '@nestjs/common';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsNumber, ValidateIf, ValidationOptions } from 'class-validator';
|
||||
|
||||
export function IsNullableNumber(options?: ValidationOptions): PropertyDecorator {
|
||||
return applyDecorators(
|
||||
Transform(({ value }) => (value === null ? null : Number(value))),
|
||||
ValidateIf((_, value) => value !== null),
|
||||
IsNumber({}, options),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user