Class: JSONSchemer::Draft202012::Vocab::Core::UnknownKeyword
- Inherits:
-
Keyword
- Object
- Keyword
- JSONSchemer::Draft202012::Vocab::Core::UnknownKeyword
show all
- Defined in:
- lib/json_schemer/draft202012/vocab/core.rb
Constant Summary
Constants included
from Output
Output::FRAGMENT_ENCODE_REGEX
Instance Attribute Summary
Attributes inherited from Keyword
#parent, #parsed, #root, #value
Attributes included from Output
#keyword, #schema
Instance Method Summary
collapse
Methods inherited from Keyword
#absolute_keyword_location, #initialize, #schema_pointer
Instance Method Details
#fetch_unknown!(token) ⇒ Object
133
134
135
136
137
138
139
140
141
|
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 133
def fetch_unknown!(token)
if value.is_a?(Hash)
parsed[token] ||= JSONSchemer::Schema::UNKNOWN_KEYWORD_CLASS.new(value.fetch(token), self, token, schema)
elsif value.is_a?(Array)
parsed[token.to_i] ||= JSONSchemer::Schema::UNKNOWN_KEYWORD_CLASS.new(value.fetch(token.to_i), self, token, schema)
else
raise KeyError.new(:receiver => parsed, :key => token)
end
end
|
#parse ⇒ Object
123
124
125
126
127
128
129
130
131
|
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 123
def parse
if value.is_a?(Hash)
{}
elsif value.is_a?(Array)
[]
else
value
end
end
|
#unknown_schema! ⇒ Object
143
144
145
|
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 143
def unknown_schema!
@unknown_schema ||= subschema(value)
end
|
#validate(instance, instance_location, keyword_location, _context) ⇒ Object
147
148
149
|
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 147
def validate(instance, instance_location, keyword_location, _context)
result(instance, instance_location, keyword_location, true, :annotation => value)
end
|