Is it possible to do shared validators? For example build a DTO with class-validator for array, string, number validators that can be used in other places.
function(@Query('id') id:QueryNumberDto)
import { IsNumber, Max, IsNotEmpty } from 'class-validator';
import { Transform } from 'class-transformer'
export class id:QueryNumberDto {
@IsNumber()
@IsNotEmpty()
@Transform(value => Number(value))
(dynamic): Number;
}
something like that, that in error i can return a dynamic field
You can create own validators https://github.com/typestack/class-validator#custom-validation-decorators or inherit from another classes https://github.com/typestack/class-validator#inheriting-validation-decorators.
You can also create a new Decorator for your Validator, that calls the other decorators. In JS/TS decorators are just functions that are called.
@pietrobelluno
https://github.com/tannerntannern/ts-mixer#mixing-with-decorators
Most helpful comment
You can also create a new Decorator for your Validator, that calls the other decorators. In JS/TS decorators are just functions that are called.