Module: JSONSchemer::Format::JSONPointer

Included in:
JSONSchemer::Format
Defined in:
lib/json_schemer/format/json_pointer.rb

Constant Summary collapse

JSON_POINTER_REGEX_STRING =
'(\/([^~\/]|~[01])*)*'
JSON_POINTER_REGEX =
/\A#{JSON_POINTER_REGEX_STRING}\z/.freeze
RELATIVE_JSON_POINTER_REGEX =
/\A(0|[1-9]\d*)(#|#{JSON_POINTER_REGEX_STRING})?\z/.freeze

Instance Method Summary collapse

Instance Method Details

#valid_json_pointer?(data) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/json_schemer/format/json_pointer.rb', line 9

def valid_json_pointer?(data)
  JSON_POINTER_REGEX.match?(data)
end

#valid_relative_json_pointer?(data) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/json_schemer/format/json_pointer.rb', line 13

def valid_relative_json_pointer?(data)
  RELATIVE_JSON_POINTER_REGEX.match?(data)
end