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.

Dont run validates_schema if individual fields were invalid

See original GitHub issue

I just discovered that validates_schema runs if individual fields have failed validation. I kinda expected otherwise.

I want a way to prevent validates_schema from being run if individual fields have failed validation. Please confirm if my way of comparing original and processed data is sufficient or that there is a simpler alternative.

@validates_schema(pass_original=True)
def validate_schema(self, data, original):
    # dont run below tests if validation on individual fields failed:
    if sorted(data.keys()) != sorted(original.keys()):
        return
    ...tests that presume individual fields are valid

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sloriacommented, Dec 8, 2015

The skip_on_field_errors parameter has been added to validates_schema in 2.4.0.

1reaction
DamianHeardcommented, Nov 26, 2015

Perhaps an alternative would be to properly expose the errors that have been captured during unmarshalling. At the moment you have to go through self._unmarshal.errors. Individual validate_schema methods would either check for errors before running of the decorator could be modified to automatically do this check if configured. Of course, I could be missing something and these errors might be already getting exposed at a more desirable location.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Validating Schema using RestAssured ...
OK. The problem is as I suspected, you are providing JSON data as opposed to a JSON Schema. Generating the Schema from your...
Read more >
Invalid schema causes "should have required property '$ref ...
When an OpenAPI v3 Response Object contains a schema which has invalid schemas, an error is thrown saying: should have a required $ref...
Read more >
How to Fix Schema Validation Errors
The most common schema validation error is "either "offers", "review", or "aggregate rating" should be specified." Here's how to fix it.
Read more >
How To Use Schema Validation in MongoDB - DigitalOcean
This tutorial was validated using a server running Ubuntu 20.04, ... In MongoDB, schema validation works on individual collections by ...
Read more >
Kubernetes Schema Validation | Datree.io
Running schema validation tests is important, and the sooner the better. ... Are you sure you don't have any invalid data types?
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