{"issue":{"pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"state":"open","user":{"avatar_url":"https://secure.gravatar.com/avatar/c0240424425f5ca75071b478c0dc29b9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"c0240424425f5ca75071b478c0dc29b9","url":"https://api.github.com/users/n1k0","login":"n1k0","id":41547},"milestone":null,"labels":[],"assignee":null,"updated_at":"2011-10-27T11:05:07Z","closed_at":null,"comments":18,"url":"https://api.github.com/repos/hmarr/mongoengine/issues/328","body":"As far as I can see, validating a `ComplexBaseField` won't give all the validation errors but only the first one encountered. Also, errors on `EmbeddedDocumentField` will just give something like `'Invalid EmbeddedDocumentField item (FooBaz)'`which is hard to debug, to say the least.\r\n\r\nWhat would be cool is to have access to some property in the `ValidationError` instance, eg. an `errors` one which could give something like:\r\n\r\n``` python\r\ndef print_errors(errors):\r\n    for field_name, error in errors.iteritems():\r\n        if isinstance(error, dict):\r\n            print_errors(error)\r\n        else:\r\n            print 'error for %s: %s' % (field_name, error, )\r\n\r\ntry:\r\n    obj.validate()\r\nexcept ValidationError, err:\r\n    print_errors(err.errors)\r\n```\r\n\r\nThe `errors` property would basically contain a ditionnary with the validation errors:\r\n\r\n``` python\r\nerrors = {\r\n    'field1': {\r\n        'subfield1': 'this field is required',\r\n        'subfield2': 'wrong type provided',\r\n    },\r\n    'field2': 'Email is invalid',\r\n}\r\n```\r\n\r\nI can eventually work on a patch in my fork, but I would love to hear your thoughts and feedback on this proposition first.","html_url":"https://github.com/hmarr/mongoengine/issues/328","title":"Retrieve all validation errors for ComplexBaseField, recursively","number":328,"id":2022601,"created_at":"2011-10-22T13:38:37Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/c0240424425f5ca75071b478c0dc29b9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"c0240424425f5ca75071b478c0dc29b9","url":"https://api.github.com/users/n1k0","login":"n1k0","id":41547},"updated_at":"2011-10-27T11:05:07Z","url":"https://api.github.com/repos/hmarr/mongoengine/issues/comments/2542168","body":"> And, IMO, extend this behaviour to whole document validation too.\r\n\r\nWell it is the case atm, or am I misunderstanding what you say? :)\r\n\r\nLook at the test: https://github.com/n1k0/mongoengine/blob/validation-schema/tests/fields.py#L1565","id":2542168,"created_at":"2011-10-27T11:05:07Z"}}