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.

Hi everyone !!

I having some troubles with dump. I want the lib raise a error when some variables in object is missing.

I made the test bellow to explain and the assert failed because nothing is raised.

Is it a bug of dump?

` from marshmallow import Schema, fields

def test_dump():

class TesteClass:
    def __init__(self):
        self.variable_a = 1

class TesteSchemaClass(Schema):
    variable_a = fields.Integer(required=True)
    variable_b = fields.Integer(required=True)

teste = TesteClass()

schema = TesteSchemaClass()

data, error = schema.dump(teste)

assert len(error.keys()) == 1

`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
deckar01commented, Mar 24, 2020

The correct way to do this is to dump the data, then load it. If the data types are wrong you will probably get errors during dump. This is how it always worked, you just get the real errors instead of ValidationErrors now. If the values are wrong, you will get ValidationErrors during the load operation.

2reactions
deckar01commented, Feb 7, 2019

Schema.dump() also returns a dictionary of errors, which will include any ValidationErrors raised during serialization. However, required, allow_none, validate, @validates, and @validates_schema only apply during deserialization.

https://marshmallow.readthedocs.io/en/3.0/quickstart.html#validation

Not being able to trust the structure of the object is usually a sign that it is actually data that needs to be loaded. You can use schema.validate(data), but under the hood it is doing the same thing as schema.load(data), it just returns the errors instead of raising them.

https://marshmallow.readthedocs.io/en/3.0/api_reference.html#marshmallow.Schema.validate

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Validate A DataPump Export (EXPDP) Dump File ?
How to confirm that expdp dump files are valid and can be successfully imported into a target environment?
Read more >
Landfill Waste Diversion Validation - UL Solutions
UL Solutions offers landfill waste diversion claim validations to recognize companies that handle waste in environmentally responsible and innovative ways.
Read more >
How to use Dumpchk.exe to check a Memory Dump file
By default, Dumpchk.exe is installed to the Program Files\Support Tools folder. ... -? Displays the command syntax. -p Prints the header only (with...
Read more >
Master / Transaction data Dump / Validation before DMO ...
Master / Transaction data Dump / Validation before DMO / SUM update ... We would like to know what data dumps that we...
Read more >
Quickstart — marshmallow 3.19.0 documentation
Serialize objects by passing them to your schema's dump method, which returns the ... with a dictionary of validation errors, which we'll revisit...
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