How to validate an Image extension with Express Validator?

698 views Asked by At

Good nigth to everyone. Im just finishing my first course to start programming and Im having lot of problems to validate an image extension using express-validator.

I need to validate an image to be "PNG", "JPEG", "JPG", or "GIF". I tried a few things but nothing worked. Some advice will be great for me, thank you in advanced.

1

There are 1 answers

0
Lyes On

The validator package would be more adaptable for this stuff, you can use isIn for this

req.checkBody( "your extension" ).isIn([ "PNG", "JPEG", "GIF" ]);