lowest_threshold_amount: decimal_t @V.IsEnum($ESynchronizePriceRuleStatus) status: $ESynchronizePriceRuleStatus }//写法如下:@V.IsOptional() @V.ValidateNested() @V.Type(()=>SynchronizePriceRule) synchronize_price_rule: SynchronizePriceRule
因为类型在运行时消失了。您可以创建枚举并使用IsEnum装饰器进行验证。Example
@IsEnum(entity: object) Checks if the value is a valid enum Number validation decorators @IsDivisibleBy(num: number) Checks if the value is a number that's divisible by another. @IsPositive() Checks if the value is a positive number greater than zero. ...
比如我有个参数叫 classType , 是字符串数组,值只能是 "a" 或者 "b", 也可以同时两个,所以希望设置输入参数的时候只能是这3个 ["a"] ["b"] ["a","b"] ,这个在 class-validator 要如何设置? @IsArray() // @IsEnum(['a', 'b']) 我一开始是这样设置的,但是不行,只 classType = ["a"]...
@IsEnum(entity: object) Checks if the value is an valid enum 是否是有效的枚举 Number validation decorators 数字验证装饰器 修饰器描述(英文)描述(中文) @IsDivisibleBy(num: number) Checks if the value is a number that’s divisible by another. 是否是可以被另一个数整除的数 @IsPositive() Che...
threshold_amount: boolean_t @V.IsDecimal()lowest_threshold_amount: decimal_t @V.IsEnum($ESynchronizePriceRuleStatus)status: $ESynchronizePriceRuleStatus } // 写法如下:@V.IsOptional()@V.ValidateNested()@V.Type(() => SynchronizePriceRule)synchronize_price_rule: SynchronizePriceRule ...
Nestjs IsEnum数据验证和swagger 、 这可以很好地工作: import { IsIn } from 'class-validator'; }) } 在swagger1, Minor = 3, Warning = 浏览83提问于2020-06-10得票数 2 回答已采纳 1回答 NestJs/Swagger:如何在现有的DTO类上添加“附加属性: false`” 、、、 你好,我是Nestjs新手,我试图在一...
IsEnum(entity: object) IsObject 判断是否是一个对象 IsNotEmptyObject() 不是空对象 常用校验器 IsDefined 不能等于null或者undefined 空字符串可以的 IsOptional 常用 可选的。如果输入的等于null或者undefined,忽略其它的校验装饰器 Equals 等于某个确定的值 ...
@IsEnum(entity: object)Checks if the value is an valid enum是否是有效的枚举 Number validation decorators 数字验证装饰器 修饰器描述(英⽂)描述(中⽂)@IsDivisibleBy(num: number)Checks if the value is a number that’s divisible by another.是否是可以被另⼀个数整除的数 @IsPositive()...
// ...additionalConverters:{[ValidationTypes.IS_EMPTY]:{anyOf:[{type:'string',enum:['']},{type:'null'}]}} TODO [x] handleskipMissingPropertiesand@isDefined() [x] decorators for overwriting prop schemas [ ] optional property descriptions (e.g.A Base64-encoded string) ...