File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -338,6 +338,33 @@ def is_json_pointer(instance):
338
338
return jsonpointer .JsonPointer (instance )
339
339
340
340
341
+ # TODO: I don't want to maintain this, so it
342
+ # needs to go either into jsonpointer (pending
343
+ # https://github.com/stefankoegl/python-json-pointer/issues/34) or
344
+ # into a new external library.
345
+ @_checks_drafts (
346
+ draft7 = "relative-json-pointer" ,
347
+ raises = jsonpointer .JsonPointerException ,
348
+ )
349
+ def is_relative_json_pointer (instance ):
350
+ # Definition taken from:
351
+ # https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01#section-3
352
+ if not isinstance (instance , str_types ):
353
+ return True
354
+ non_negative_integer , rest = [], ""
355
+ for i , character in enumerate (instance ):
356
+ if character .isdigit ():
357
+ non_negative_integer .append (character )
358
+ continue
359
+
360
+ if not non_negative_integer :
361
+ return False
362
+
363
+ rest = instance [i :]
364
+ break
365
+ return (rest == "#" ) or jsonpointer .JsonPointer (rest )
366
+
367
+
341
368
try :
342
369
import uritemplate .exceptions
343
370
except ImportError :
You can’t perform that action at this time.
0 commit comments