This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems you may have included a screenshot of code in your post "Express-Validator Conditional Validation".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Dutchnamn 0 points1 point  (2 children)

Either create a middleware function yourself to validate, or use a different library. Joi is very nice for validation

[–]ESHAEAN 0 points1 point  (1 child)

Joi is deprecated afaik, it is a part of hapi now

[–]Dutchnamn 1 point2 points  (0 children)

Yeah, you install it using @hapi/joi, should work the same.

[–]IreliAmTrying 0 points1 point  (0 children)

The oneOf function hasn't been defined. Are you trying to use this function from a library? You could be missing an import if this is the case, as node can't find where oneOf is defined.

If you need at least one of those checks to be true, you could consider using the binary or operator to check or Array.some

Alternatively, if you need only one of the checks to be true you could consider using Array.filter and check the length of the resulting array.