File: json_pointer.rb

package info (click to toggle)
ruby-json-schemer 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 544 kB
  • sloc: ruby: 7,428; makefile: 4; sh: 4
file content (18 lines) | stat: -rw-r--r-- 519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true
module JSONSchemer
  module Format
    module JSONPointer
      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

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

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