Module: ElasticGraph::JSONSchema::MetaSchemaLoader
- Defined in:
- lib/elastic_graph/json_schema/meta_schema_validator.rb
Overview
Responsible for building Validators that can validate JSON schema definitions.
Class Method Summary collapse
-
.load_strict_validator(overrides = {}) ⇒ Object
Builds a validator to validate a JSON schema definition according to the JSON schema meta schema.
Class Method Details
.load_strict_validator(overrides = {}) ⇒ Object
Builds a validator to validate a JSON schema definition according to the JSON schema meta schema.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/elastic_graph/json_schema/meta_schema_validator.rb', line 52 def self.load_strict_validator(overrides = {}) # Downloaded from: https://json-schema.org/draft-07/schema schema = ::JSON.parse(::File.read(::File.("../json_schema_draft_7_schema.json", __FILE__))) schema = Support::HashUtil.deep_merge(schema, overrides) unless overrides.empty? # The meta schema allows additionalProperties in nearly every place. While a JSON schema definition # with additional properties is considered valid, we do not intend to use any additional properties, # and any usage of an additional property is almost certainly a typo. So here we set # `with_unknown_properties_disallowed`. root_schema = ValidatorFactory.new(schema: schema, sanitize_pii: false) # The meta schema has no PII .with_unknown_properties_disallowed .root_schema Validator.new(schema: root_schema, sanitize_pii: false) end |