{"action":"created","issue":{"url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/124","labels_url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/124/comments","events_url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/124/events","html_url":"https://github.com/umutbozkurt/django-rest-framework-mongoengine/issues/124","id":111226493,"number":124,"title":"Are embedded documents validated? ","user":{"login":"qwiglydee","id":285128,"avatar_url":"https://avatars.githubusercontent.com/u/285128?v=3","gravatar_id":"","url":"https://api.github.com/users/qwiglydee","html_url":"https://github.com/qwiglydee","followers_url":"https://api.github.com/users/qwiglydee/followers","following_url":"https://api.github.com/users/qwiglydee/following{/other_user}","gists_url":"https://api.github.com/users/qwiglydee/gists{/gist_id}","starred_url":"https://api.github.com/users/qwiglydee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwiglydee/subscriptions","organizations_url":"https://api.github.com/users/qwiglydee/orgs","repos_url":"https://api.github.com/users/qwiglydee/repos","events_url":"https://api.github.com/users/qwiglydee/events{/privacy}","received_events_url":"https://api.github.com/users/qwiglydee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-13T17:12:57Z","updated_at":"2015-10-13T17:22:50Z","closed_at":null,"body":"Using old 2.0.2 with optik's patch from issue#72 for embedded documents\r\n\r\nThe relevant parts of structures I have:\r\n```python\r\nclass Ankette(Timeable, Document):\r\n    class HasAuto(EmbeddedDocument):\r\n        kind = fields.StringField(required=True, choices=('седан', 'универсал', 'внедорожник'))\r\n        model = fields.StringField()\r\n\r\n    hasauto = fields.EmbeddedDocumentField(HasAuto) # (not required by itself)\r\n\r\nclass AnkSerializer(DocumentSerializer):\r\n    class Meta:\r\n        model = Ankette\r\n    # the field for hasauto autogenerated\r\n\r\nclass AnkAPI(CompanyMixin, CommonView):\r\n    model = Ankette\r\n    queryset = Ankette.objects\r\n    serializer_class = AnkSerializer\r\n\r\n    # from  CommonView, it has 'PUT' mapped to partial_update from mixins.UpdateModelMixin: \r\n    def partial_update(self, request, *args, **kwargs):\r\n        kwargs['partial'] = True\r\n        return self.update(request, *args, **kwargs) \r\n\r\n    def update(self, request, *args, **kwargs):\r\n        partial = kwargs.pop('partial', False)\r\n        instance = self.get_object()\r\n        serializer = self.get_serializer(instance, data=request.data, partial=partial)\r\n        serializer.is_valid(raise_exception=True)\r\n        self.perform_update(serializer) ...\r\n        return Response(serializer.data)\r\n```\r\n\r\nNow, when I PUT ```{\"hasauto\":{\"model\":\"foo\"}}``` I expect HTTP 400 ValidationError to be returned, with some pretty details in body. Instead I got HTTP 500 because of mongoengine.ValidationError raised at mongoengine/base/document.py in validate.\r\n\r\nMethod is_valid ignores field requirement somehow. And I cannot figure out - why? \r\n"},"comment":{"url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/comments/147783468","html_url":"https://github.com/umutbozkurt/django-rest-framework-mongoengine/issues/124#issuecomment-147783468","issue_url":"https://api.github.com/repos/umutbozkurt/django-rest-framework-mongoengine/issues/124","id":147783468,"user":{"login":"qwiglydee","id":285128,"avatar_url":"https://avatars.githubusercontent.com/u/285128?v=3","gravatar_id":"","url":"https://api.github.com/users/qwiglydee","html_url":"https://github.com/qwiglydee","followers_url":"https://api.github.com/users/qwiglydee/followers","following_url":"https://api.github.com/users/qwiglydee/following{/other_user}","gists_url":"https://api.github.com/users/qwiglydee/gists{/gist_id}","starred_url":"https://api.github.com/users/qwiglydee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwiglydee/subscriptions","organizations_url":"https://api.github.com/users/qwiglydee/orgs","repos_url":"https://api.github.com/users/qwiglydee/repos","events_url":"https://api.github.com/users/qwiglydee/events{/privacy}","received_events_url":"https://api.github.com/users/qwiglydee/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T17:22:50Z","updated_at":"2015-10-13T17:22:50Z","body":"The exact message is:\r\n```\r\nGot a `ValidationError` when calling `Ankette.objects.create()`. This may be because request data satisfies serializer validations but not Mongoengine`s. You may need to check consistency between Ankette and AnkSerializer.\r\nIf that is not the case, please open a ticket regarding this issue on https://github.com/umutbozkurt/django-rest-framework-mongoengine/issues\r\nOriginal exception was: ValidationError (Ankette:None) (kind.Field is required: ['hasauto'])\r\n```\r\n"}}