diff --git a/src/plone/restapi/deserializer/dxcontent.py b/src/plone/restapi/deserializer/dxcontent.py index dd6bac1851..eb3035f620 100644 --- a/src/plone/restapi/deserializer/dxcontent.py +++ b/src/plone/restapi/deserializer/dxcontent.py @@ -24,6 +24,11 @@ from zope.schema.interfaces import ValidationError from zope.security.interfaces import IPermission +import logging + + +logger = logging.getLogger(__name__) + @implementer(IDeserializeFromJson) @adapter(IDexterityContent, Interface) @@ -37,7 +42,12 @@ def __init__(self, context, request): self.modified = {} def __call__( - self, validate_all=False, data=None, create=False, mask_validation_errors=True + self, + validate_all=False, + data=None, + create=False, + mask_validation_errors=True, + ignore_errors=False, ): # noqa: ignore=C901 if data is None: @@ -61,7 +71,10 @@ def __call__( error["error"] = "ValidationError" for error in errors: error["message"] = translate(error["message"], context=self.request) - raise BadRequest(errors) + if ignore_errors: + logger.warn("Ignoring validation errors: %s", errors) + else: + raise BadRequest(errors) # We'll set the layout after the validation and even if there # are no other changes.