From a7ef7e80d0024b71794c22fd09e35389c04de964 Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Tue, 17 Nov 2020 08:15:25 -0500 Subject: fix #110: Validate patch documents during creation. --- jsonpatch.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'jsonpatch.py') diff --git a/jsonpatch.py b/jsonpatch.py index 7d5489a..022972b 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -222,6 +222,9 @@ class JsonPatch(object): 'copy': CopyOperation, } + for op in self.patch: + self._get_operation(op) + def __str__(self): """str(self) -> self.to_string()""" return self.to_string() -- cgit v1.2.1 From 3bb33518194b0cbc6e1512dbeb2ac5ef548d8c72 Mon Sep 17 00:00:00 2001 From: Dave Shawley Date: Fri, 20 Nov 2020 07:22:03 -0500 Subject: Explain the call to _get_operation in __init__. --- jsonpatch.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'jsonpatch.py') diff --git a/jsonpatch.py b/jsonpatch.py index 022972b..2b8678f 100644 --- a/jsonpatch.py +++ b/jsonpatch.py @@ -222,6 +222,10 @@ class JsonPatch(object): 'copy': CopyOperation, } + # Verify that the structure of the patch document + # is correct by retrieving each patch element. + # Much of the validation is done in the initializer + # though some is delayed until the patch is applied. for op in self.patch: self._get_operation(op) -- cgit v1.2.1