module SimpleJSONSchema::Checker
Constants
- JSON_POINTER_REGEX
- JSON_POINTER_REGEX_STRING
- RELATIVE_JSON_POINTER_REGEX
Public Class Methods
at_size(scope, check, operation)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 15 def at_size(scope, check, operation) over = scope[check] scope.error(check, count: over) if over && scope.value&.size&.public_send(operation, over) end
at_value(scope, check, operation)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 10 def at_value(scope, check, operation) over = scope[check] scope.error(check, count: over) if over && scope.value&.public_send(operation, over) end
const(scope)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 38 def const(scope) return if scope.segment.is_a?(Array) scope.error(:const) if scope.key?(:const) && scope[:const] != scope.value end
enum(scope)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 33 def enum(scope) enum = scope[:enum] scope.error(:enum) if enum && !enum.include?(scope.value) end
json_pointer?(value)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 44 def json_pointer?(value) JSON_POINTER_REGEX.match?(value) end
relative_json_pointer?(value)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 48 def relative_json_pointer?(value) RELATIVE_JSON_POINTER_REGEX.match?(value) end
required_keys(scope)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 20 def required_keys(scope) required = scope[:required] return unless required.is_a?(Array) missing_keys = required - scope.value.keys scope.error(:required, missing_keys: missing_keys) if missing_keys.any? end
unique_items(scope)
click to toggle source
# File lib/simple_json_schema/checker.rb, line 28 def unique_items(scope) value = scope.value scope.error(:uniqueItems) if scope[:uniqueItems] && value.size != value.uniq.size end