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.

Enforce request body match validation schema

See original GitHub issue

@fedeci

How to make sure the schema of the body is exactly of this form.

{
    'name': ...
    'description': ...
}

I mean if the body contains other fields than these (name, description), then I want to signal them by raising an exception.

Ex:

{
    'name': 'Bob'
    'description': 'Card player'
    'age' : 54
}

In this case, the validation should fail because the field age is not part of the wanted schema.

Obviously, it’s possible to create a custom task, but it would be a great asset to have this functionality in express-validator. Some kind of matchSchema(true)?

Duplicate of https://github.com/express-validator/express-validator/issues/1101#issuecomment-1112320481 but this issue has been closed.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tonysampericommented, Jun 13, 2022

@erakis That’s integrated! You can chain that validation with all the others… As per deep validation, as I said, you just do some refactor using recursion… Here in Italy we say “Non esiste la pappa pronta”, which means you can’t find exactly what you need nice and ready to use 😃 Cheers

1reaction
fedecicommented, Jun 16, 2022

It would, just be sure to open and develop it against the v7-features branch!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validate Request Body in RESTful Web Service
In this tutorial, you will learn how to validate the request body of an HTTP Post request sent to a RESTful Web Service...
Read more >
Schema Validation in Go using Validator and Fiber
Now let's validate the request body and if there was any error, the request will not go to the next handler and the...
Read more >
Validate request body separately from request as a whole
I do need it to be executed as long as part of the schema is correct (correct headers), and the body is an...
Read more >
Using JSON Schema Validation with the AWS API Gateway
If you want to accept JSON payloads from POST requests that contain data created by your frontend client you may end up needing...
Read more >
Enable request validation in API Gateway - AWS Documentation
Learn how to enable request validation on methods for API Gateway. You can validate a request body by specifying a model schema or...
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