Both req.files and req.file must be considered for handling multipart/form-data validation. This is necessary to allow uploading of a single file with multer. Otherwise something like upload.single("image") will not work.
This is a small and important fix. However, it does not improve the validation itself. Without this fix, uploading a single file will cause requestOptions.files to be undefined. But the validation passes anyway. The same when no file is uploaded at all!
Both
req.files
andreq.file
must be considered for handlingmultipart/form-data
validation. This is necessary to allow uploading of a single file with multer. Otherwise something likeupload.single("image")
will not work.This is a small and important fix. However, it does not improve the validation itself. Without this fix, uploading a single file will cause
requestOptions.files
to beundefined
. But the validation passes anyway. The same when no file is uploaded at all!