Skip to content

Commit e236bed

Browse files
committed
Dexterity deserializer: Allow to ignore validation errors.
1 parent 1bfea10 commit e236bed

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/plone/restapi/deserializer/dxcontent.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
from zope.schema.interfaces import ValidationError
2424
from zope.security.interfaces import IPermission
2525

26+
import logging
27+
28+
29+
logger = logging.getLogger(__name__)
30+
2631

2732
@implementer(IDeserializeFromJson)
2833
@adapter(IDexterityContent, Interface)
@@ -36,7 +41,12 @@ def __init__(self, context, request):
3641
self.modified = {}
3742

3843
def __call__(
39-
self, validate_all=False, data=None, create=False, mask_validation_errors=True
44+
self,
45+
validate_all=False,
46+
data=None,
47+
create=False,
48+
mask_validation_errors=True,
49+
ignore_errors=False,
4050
): # noqa: ignore=C901
4151
if data is None:
4252
data = json_body(self.request)
@@ -57,7 +67,10 @@ def __call__(
5767
# errors on front-end
5868
for error in errors:
5969
error["error"] = "ValidationError"
60-
raise BadRequest(errors)
70+
if ignore_errors:
71+
logger.warn("Ignoring validation errors: %s", errors)
72+
else:
73+
raise BadRequest(errors)
6174

6275
# We'll set the layout after the validation and even if there
6376
# are no other changes.

0 commit comments

Comments
 (0)