-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In my project I'm using multer together with Joi to validate incoming body requests. I've noticed this was giving me an error of undefined while other non multipart type requests going through body-parser worked just fine. I managed to track the error to the fact that Joi uses hasOwnProperty on req.body while multer instantiates req.body on null as Object.create(null), this can be found here. Therefore none of the global object functions are available to use on req.body.
It might be nice to instantiate req.body as an object literal {} or Object.create(Object.prototype) to have those methods available on the parsed body for further use down the middleware chain. Body parser already does this as you can see here.
Let me know what you think and if you agree. I can submit a quick PR if you want to.