question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Best practices regarding unknown properties

See original GitHub issue

Requests can be validated via a custom schema, e.g.

req.checkBody({
  email: { ...
});

which is great. Are there any guidelines what to do, if the request should only contain the email property and nothing else? For example the following request body should cause validation to fail

{
  "email": "example@example.org",
  "extra": "I should not be here!"
}

with an error message along the lines of Unknown property "extra".

Any thoughts / hints appreciated! 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Maddoc42commented, Oct 20, 2016

Nice, thanks for the reference! 👍 that’s pretty much my use case actually, the solution with lodash

var requestParams = _.pick(req.body, _.keys(validationMap));

pretty much solves my problem! 🎉

Primary difference to this issue is that, rejecting unknown properties in a request could help potential client API developers. I’ll keep this open as a reference 📘

0reactions
lock[bot]commented, Jun 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Ignore Unknown Properties While Parsing JSON in ...
Though, the preferred approach is to ignore unknown properties at the class level using @JsonIgnoreProperties(ignoreUnknown = true) and only do this on the ......
Read more >
Best practices
This guide is a work in progress and is not currently complete. Feel free to contact us to propose topics that should be...
Read more >
How to handle unknown properties and methods using ...
Learn Swift coding for iOS with these free tutorials.
Read more >
How to Ignore Unknown Properties While ... - GeeksforGeeks
However, the preferred approach is to ignore unknown properties at the class level using @JsonIgnoreProperties(ignoreUnknown = true) and only do ...
Read more >
REST Assured Tutorial 41 – Ignore unknown properties during ...
Learn to ignore unknown properties during deserialization using @JsonIgnoreProperties of Jackson API in Java. ignoreUnknown property of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found