summaryrefslogtreecommitdiff
path: root/jsonpatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonpatch.py')
-rw-r--r--jsonpatch.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/jsonpatch.py b/jsonpatch.py
index e042ce2..7d5489a 100644
--- a/jsonpatch.py
+++ b/jsonpatch.py
@@ -334,12 +334,18 @@ class PatchOperation(object):
def __init__(self, operation):
+ if not operation.__contains__('path'):
+ raise InvalidJsonPatch("Operation must have a 'path' member")
+
if isinstance(operation['path'], JsonPointer):
self.location = operation['path'].path
self.pointer = operation['path']
else:
self.location = operation['path']
- self.pointer = JsonPointer(self.location)
+ try:
+ self.pointer = JsonPointer(self.location)
+ except TypeError as ex:
+ raise InvalidJsonPatch("Invalid 'path'")
self.operation = operation