Dump Validation
See original GitHub issueHi 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:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top 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 >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
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 ofValidationError
s now. If the values are wrong, you will getValidationErrors
during theload
operation.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 asschema.load(data)
, it just returns the errors instead of raising them.https://marshmallow.readthedocs.io/en/3.0/api_reference.html#marshmallow.Schema.validate