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.

[BUG] Nested document validation is broken

See original GitHub issue

Nested document validation seems to be broken in master branch. After a bit of debugging it seems that this is due to the fact that self.document attribute of subdocument validators gets assigned with a copy of the contents of the parent document (context) causing further validation steps to fail.

To reproduce

import cerberus

schema = {
    'info': {
        'type': 'dict',
        'schema': {
            'name': {'type': 'string', 'required': True}
        }
    }
}

validator = cerberus.Validator(schema)
res = validator.validate({'info': {'name': 'my name'}})
if not res:
    print validator._errors

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
funkyfuturecommented, Jun 9, 2015

hm, this doesn’t fail.

what’s actually the output of your code above?

0reactions
funkyfuturecommented, Jun 13, 2015

that’s a nasty one, see #111 for some progress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongoose nested schema validation not working
This will give a validation error on the first document: ValidationError: Path `quantity` is required. Share.
Read more >
Built-In, Nested, Custom Validators with FluentValidation
This very handy validator covers all the various email formats and edge cases so that we don't need to. Enum Validation. Most .NET...
Read more >
Refactoring-safe nested validation with express-validator and ...
This is not type and refactoring safe, hence error prone. ... Finds the validation errors in this request and wraps them in an...
Read more >
validate.js
Otherwise an object in this format is returned: {<attribute>: [<error>, <error>, ... Validate.js also has limited support for nested objects (objects within ...
Read more >
Error Explanations for The W3C Markup Validation Service
This error may appear when the validator receives an empty document. Please make sure that the document you are uploading is not empty,...
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