You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
I have such construction in couple of places
importtype{Schema}from'express-validator';exportconstschema: Schema={orderId: {// @ts-ignore TODO: no type in express-validator but worksif: {options: (v,{ req })=>condition
? !v
: false,},isInt: true,toInt: true,},};
It worked before on version 6.2.0, but as you can see I used @ts-ignore because without it had error "Object literal may only specify known properties, and 'if' does not exist in type 'ParamSchema"
But now, after I updated express-validator to 7.0.1 this not working anymore and also I have error inside my console after build "express-validator: schema of "orderId" has unknown validator/sanitizer "if""
That why i decided to finally create issue and ask: Is it me doing something wrong? Link to documentation express-validator.github.io/docs/api/check-schema#if Seems like I should use if only inside validator, like this?
But will it ignore everything(other validators, customs, sanitizers) after "isInt" key or only validators?
Yes it will ignore everything after isInt. We decided to move it because now you can add more than one if and place it accurately before a chosen validator.
Behind the scenes checkSchema behaves like a validation chain and validators are run in the same order they are added to the object. I know this is a little bit counter-intuitive because order in objects usually doesn't matter, but in this case it does.
Hello.
I have such construction in couple of places
It worked before on version 6.2.0, but as you can see I used @ts-ignore because without it had error "Object literal may only specify known properties, and 'if' does not exist in type 'ParamSchema"
But now, after I updated express-validator to 7.0.1 this not working anymore and also I have error inside my console after build "express-validator: schema of "orderId" has unknown validator/sanitizer "if""
That why i decided to finally create issue and ask: Is it me doing something wrong?
Link to documentation https://express-validator.github.io/docs/api/check-schema#if
Seems like I should use if only inside validator, like this?
But will it ignore everything(other validators, customs, sanitizers) after "isInt" key or only validators?
The text was updated successfully, but these errors were encountered: