Is it possible to check which combination of req.body properties has been sent by client?
See original GitHub issueHow can we access req.body
in validator?
We have a need to inspect the combination of properties (not their values, but properties) client has sent to an API endpoint. So, we don’t want to validate any particular property value but we need to access req.body
in validator and then do validation based on Object.keys(req.body)
.
Is there an elegant way of doing something like that?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
req.body empty on posts - node.js - Stack Overflow
You have to check whether the body-parser middleware is set properly to the type of request(json, urlencoded). If you have set, app.use(bodyParser.json());.
Read more >How To Use the req Object in Express - DigitalOcean
Express servers receive data from the client side through the req object in three instances: the req.params , req.query , and req.body objects....
Read more >Express.js req.body Property - GeeksforGeeks
The req.body property contains key-value pairs of data submitted in the request body. By default, it is undefined and is populated when you...
Read more >API Reference - Express 4.x
As req.body 's shape is based on user-controlled input, all properties and values in this object are untrusted and should be validated before...
Read more >How to handle request validation in your Express API
You can use Ajv directly, however for an Express based API it's nice to be able to use middleware to validate request data...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see. Unfortunately the most terrible way I could think of is to really use something like you mentioned:
And, just to generate some hype… This is something I could bake into version 4, soon to be released. See #383 for some preview 😉
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.