undefined
undefined

Reputation: 2119

Class Validator @ValidateIf() not working properly

I have the following class in nest js with this class validator:

 @ValidateIf(val => val !== '*')
 @IsObject()
 @IsNotEmptyObject()
 queryParams: DbQuery | '*';

If I send '*' it returns

 [ 'queryParams must be a non-empty object' ] 

Upvotes: 4

Views: 19753

Answers (1)

undefined
undefined

Reputation: 2119

For who ever finds himself here.

@ValidateIf(val => val.queryParams !== '*')
@IsNotEmptyObject()
queryParams: DbQuery | '*';

Upvotes: 10

Related Questions