jsi 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -1
  3. data/CHANGELOG.md +15 -0
  4. data/README.md +19 -18
  5. data/jsi.gemspec +2 -3
  6. data/lib/jsi/base/mutability.rb +44 -0
  7. data/lib/jsi/base/node.rb +199 -34
  8. data/lib/jsi/base.rb +412 -228
  9. data/lib/jsi/jsi_coder.rb +18 -16
  10. data/lib/jsi/metaschema_node/bootstrap_schema.rb +57 -23
  11. data/lib/jsi/metaschema_node.rb +138 -107
  12. data/lib/jsi/ptr.rb +59 -37
  13. data/lib/jsi/schema/application/child_application/draft04.rb +0 -1
  14. data/lib/jsi/schema/application/child_application/draft06.rb +0 -1
  15. data/lib/jsi/schema/application/child_application/draft07.rb +0 -1
  16. data/lib/jsi/schema/application/child_application.rb +0 -25
  17. data/lib/jsi/schema/application/inplace_application/draft04.rb +0 -1
  18. data/lib/jsi/schema/application/inplace_application/draft06.rb +0 -1
  19. data/lib/jsi/schema/application/inplace_application/draft07.rb +0 -1
  20. data/lib/jsi/schema/application/inplace_application/ref.rb +1 -1
  21. data/lib/jsi/schema/application/inplace_application/someof.rb +1 -1
  22. data/lib/jsi/schema/application/inplace_application.rb +0 -27
  23. data/lib/jsi/schema/draft04.rb +0 -1
  24. data/lib/jsi/schema/draft06.rb +0 -1
  25. data/lib/jsi/schema/draft07.rb +0 -1
  26. data/lib/jsi/schema/ref.rb +44 -18
  27. data/lib/jsi/schema/schema_ancestor_node.rb +65 -56
  28. data/lib/jsi/schema/validation/contains.rb +1 -1
  29. data/lib/jsi/schema/validation/draft04/minmax.rb +2 -0
  30. data/lib/jsi/schema/validation/draft04.rb +0 -2
  31. data/lib/jsi/schema/validation/draft06.rb +0 -2
  32. data/lib/jsi/schema/validation/draft07.rb +0 -2
  33. data/lib/jsi/schema/validation/items.rb +3 -3
  34. data/lib/jsi/schema/validation/pattern.rb +1 -1
  35. data/lib/jsi/schema/validation/properties.rb +4 -4
  36. data/lib/jsi/schema/validation/ref.rb +1 -1
  37. data/lib/jsi/schema/validation.rb +0 -2
  38. data/lib/jsi/schema.rb +405 -194
  39. data/lib/jsi/schema_classes.rb +196 -127
  40. data/lib/jsi/schema_registry.rb +66 -17
  41. data/lib/jsi/schema_set.rb +76 -30
  42. data/lib/jsi/simple_wrap.rb +2 -7
  43. data/lib/jsi/util/private/attr_struct.rb +28 -14
  44. data/lib/jsi/util/private/memo_map.rb +75 -0
  45. data/lib/jsi/util/private.rb +73 -92
  46. data/lib/jsi/util/typelike.rb +28 -28
  47. data/lib/jsi/util.rb +120 -36
  48. data/lib/jsi/validation/error.rb +4 -0
  49. data/lib/jsi/validation/result.rb +18 -32
  50. data/lib/jsi/version.rb +1 -1
  51. data/lib/jsi.rb +67 -25
  52. data/lib/schemas/json-schema.org/draft-04/schema.rb +159 -4
  53. data/lib/schemas/json-schema.org/draft-06/schema.rb +161 -4
  54. data/lib/schemas/json-schema.org/draft-07/schema.rb +188 -4
  55. metadata +19 -5
  56. data/lib/jsi/metaschema.rb +0 -6
  57. data/lib/jsi/schema/validation/core.rb +0 -39
@@ -2,13 +2,168 @@
2
2
 
3
3
  module JSI
4
4
  metaschema_document = ::JSON.parse(SCHEMAS_PATH.join('json-schema.org/draft-04/schema.json').read)
5
- JSONSchemaOrgDraft04 = MetaschemaNode.new(metaschema_document,
5
+ JSONSchemaDraft04 = JSI.new_metaschema_module(metaschema_document,
6
6
  schema_implementation_modules: [JSI::Schema::Draft04],
7
- ).jsi_schema_module
7
+ )
8
+
9
+ # in draft 4, boolean schemas are not described in the root, but on anyOf schemas on
10
+ # properties/additionalProperties and properties/additionalItems.
11
+ # these still describe schemas, despite not being described by the meta-schema.
12
+ also_describe_schemas =
13
+ JSONSchemaDraft04.schema["properties"]["additionalProperties"]["anyOf"] +
14
+ JSONSchemaDraft04.schema["properties"]["additionalItems"]["anyOf"]
15
+ also_describe_schemas.each do |schema|
16
+ schema.describes_schema!([JSI::Schema::Draft04])
17
+ end
8
18
 
9
19
  # the JSI schema module for `http://json-schema.org/draft-04/schema`
10
- module JSONSchemaOrgDraft04
11
- # @!parse extend JSI::DescribesSchemaModule
20
+ module JSONSchemaDraft04
21
+ # @!parse extend JSI::SchemaModule::MetaSchemaModule
12
22
  # @!parse include JSI::Schema::Draft04
23
+
24
+
25
+ Id = properties['id']
26
+ Xschema = properties['$schema']
27
+ Title = properties['title']
28
+ Description = properties['description']
29
+ Default = properties['default']
30
+ MultipleOf = properties['multipleOf']
31
+ Maximum = properties['maximum']
32
+ ExclusiveMaximum = properties['exclusiveMaximum']
33
+ Minimum = properties['minimum']
34
+ ExclusiveMinimum = properties['exclusiveMinimum']
35
+ MaxLength = properties['maxLength']
36
+ MinLength = properties['minLength']
37
+ Pattern = properties['pattern']
38
+ AdditionalItems = properties['additionalItems']
39
+ Items = properties['items']
40
+ MaxItems = properties['maxItems']
41
+ MinItems = properties['minItems']
42
+ UniqueItems = properties['uniqueItems']
43
+ MaxProperties = properties['maxProperties']
44
+ MinProperties = properties['minProperties']
45
+ Required = properties['required']
46
+ AdditionalProperties = properties['additionalProperties']
47
+ Definitions = properties['definitions']
48
+ Properties = properties['properties']
49
+ PatternProperties = properties['patternProperties']
50
+ Dependencies = properties['dependencies']
51
+ Enum = properties['enum']
52
+ Type = properties['type']
53
+ Format = properties['format']
54
+ AllOf = properties['allOf']
55
+ AnyOf = properties['anyOf']
56
+ OneOf = properties['oneOf']
57
+ Not = properties['not']
58
+
59
+ SchemaArray = definitions['schemaArray']
60
+ PositiveInteger = definitions['positiveInteger']
61
+ PositiveIntegerDefault0 = definitions['positiveIntegerDefault0']
62
+ SimpleType = definitions['simpleTypes']
63
+ StringArray = definitions['stringArray']
64
+
65
+ module Id
66
+ end
67
+ module Xschema
68
+ end
69
+ module Title
70
+ end
71
+ module Description
72
+ end
73
+ module Default
74
+ end
75
+ module MultipleOf
76
+ end
77
+ module Maximum
78
+ end
79
+ module ExclusiveMaximum
80
+ end
81
+ module Minimum
82
+ end
83
+ module ExclusiveMinimum
84
+ end
85
+ module MaxLength
86
+ end
87
+ module MinLength
88
+ end
89
+ module Pattern
90
+ end
91
+ module AdditionalItems
92
+ end
93
+ module Items
94
+ end
95
+ module MaxItems
96
+ end
97
+ module MinItems
98
+ end
99
+ module UniqueItems
100
+ end
101
+ module MaxProperties
102
+ end
103
+ module MinProperties
104
+ end
105
+ module Required
106
+ end
107
+ module AdditionalProperties
108
+ end
109
+ module Definitions
110
+ end
111
+ module Properties
112
+ end
113
+ module PatternProperties
114
+ end
115
+ module Dependencies
116
+ end
117
+ module Enum
118
+ end
119
+ module Type
120
+ end
121
+ module Format
122
+ end
123
+ module AllOf
124
+ end
125
+ module AnyOf
126
+ end
127
+ module OneOf
128
+ end
129
+ module Not
130
+ end
131
+
132
+ module SchemaArray
133
+ end
134
+ module PositiveInteger
135
+ end
136
+ module PositiveIntegerDefault0
137
+ end
138
+ module SimpleType
139
+ end
140
+ module StringArray
141
+ end
142
+
143
+ AdditionalItems::Boolean = AdditionalItems.anyOf[0]
144
+ AdditionalProperties::Boolean = AdditionalProperties.anyOf[0]
145
+ Dependencies::Dependency = Dependencies.additionalProperties
146
+ Type::Array = Type.anyOf[1]
147
+ PositiveIntegerDefault0::Default0 = PositiveIntegerDefault0.allOf[1]
148
+ StringItem = StringArray.items
149
+
150
+ module AdditionalItems::Boolean
151
+ end
152
+ module AdditionalProperties::Boolean
153
+ end
154
+ module Dependencies::Dependency
155
+ end
156
+ module Type::Array
157
+ end
158
+ module PositiveIntegerDefault0::Default0
159
+ end
160
+ module StringItem
161
+ end
162
+ end
163
+
164
+ JSONSchemaOrgDraft04 = JSONSchemaDraft04
165
+
166
+ # @deprecated after v0.7.0, alias of {JSONSchemaDraft04}
167
+ module JSONSchemaOrgDraft04
13
168
  end
14
169
  end
@@ -2,13 +2,170 @@
2
2
 
3
3
  module JSI
4
4
  metaschema_document = ::JSON.parse(SCHEMAS_PATH.join('json-schema.org/draft-06/schema.json').read)
5
- JSONSchemaOrgDraft06 = MetaschemaNode.new(metaschema_document,
5
+ JSONSchemaDraft06 = JSI.new_metaschema_module(metaschema_document,
6
6
  schema_implementation_modules: [JSI::Schema::Draft06],
7
- ).jsi_schema_module
7
+ )
8
8
 
9
9
  # the JSI schema module for `http://json-schema.org/draft-06/schema`
10
- module JSONSchemaOrgDraft06
11
- # @!parse extend JSI::DescribesSchemaModule
10
+ module JSONSchemaDraft06
11
+ # @!parse extend JSI::SchemaModule::MetaSchemaModule
12
12
  # @!parse include JSI::Schema::Draft06
13
+
14
+
15
+ Id = properties['$id']
16
+ Xschema = properties['$schema']
17
+ Ref = properties['$ref']
18
+ Title = properties['title']
19
+ Description = properties['description']
20
+ Default = properties['default']
21
+ Examples = properties['examples']
22
+ MultipleOf = properties['multipleOf']
23
+ Maximum = properties['maximum']
24
+ ExclusiveMaximum = properties['exclusiveMaximum']
25
+ Minimum = properties['minimum']
26
+ ExclusiveMinimum = properties['exclusiveMinimum']
27
+ MaxLength = properties['maxLength']
28
+ MinLength = properties['minLength']
29
+ Pattern = properties['pattern']
30
+ AdditionalItems = properties['additionalItems']
31
+ Items = properties['items']
32
+ MaxItems = properties['maxItems']
33
+ MinItems = properties['minItems']
34
+ UniqueItems = properties['uniqueItems']
35
+ Contains = properties['contains']
36
+ MaxProperties = properties['maxProperties']
37
+ MinProperties = properties['minProperties']
38
+ Required = properties['required']
39
+ AdditionalProperties = properties['additionalProperties']
40
+ Definitions = properties['definitions']
41
+ Properties = properties['properties']
42
+ PatternProperties = properties['patternProperties']
43
+ Dependencies = properties['dependencies']
44
+ PropertyNames = properties['propertyNames']
45
+ Const = properties['const']
46
+ Enum = properties['enum']
47
+ Type = properties['type']
48
+ Format = properties['format']
49
+ AllOf = properties['allOf']
50
+ AnyOf = properties['anyOf']
51
+ OneOf = properties['oneOf']
52
+ Not = properties['not']
53
+
54
+ SchemaArray = definitions['schemaArray']
55
+ NonNegativeInteger = definitions['nonNegativeInteger']
56
+ NonNegativeIntegerDefault0 = definitions['nonNegativeIntegerDefault0']
57
+ SimpleType = definitions['simpleTypes']
58
+ StringArray = definitions['stringArray']
59
+
60
+ module Id
61
+ end
62
+ module Xschema
63
+ end
64
+ module Ref
65
+ end
66
+ module Title
67
+ end
68
+ module Description
69
+ end
70
+ module Default
71
+ end
72
+ module Examples
73
+ end
74
+ module MultipleOf
75
+ end
76
+ module Maximum
77
+ end
78
+ module ExclusiveMaximum
79
+ end
80
+ module Minimum
81
+ end
82
+ module ExclusiveMinimum
83
+ end
84
+ module MaxLength
85
+ end
86
+ module MinLength
87
+ end
88
+ module Pattern
89
+ end
90
+ module AdditionalItems
91
+ end
92
+ module Items
93
+ end
94
+ module MaxItems
95
+ end
96
+ module MinItems
97
+ end
98
+ module UniqueItems
99
+ end
100
+ module Contains
101
+ end
102
+ module MaxProperties
103
+ end
104
+ module MinProperties
105
+ end
106
+ module Required
107
+ end
108
+ module AdditionalProperties
109
+ end
110
+ module Definitions
111
+ end
112
+ module Properties
113
+ end
114
+ module PatternProperties
115
+ end
116
+ module Dependencies
117
+ end
118
+ module PropertyNames
119
+ end
120
+ module Const
121
+ end
122
+ module Enum
123
+ end
124
+ module Type
125
+ end
126
+ module Format
127
+ end
128
+ module AllOf
129
+ end
130
+ module AnyOf
131
+ end
132
+ module OneOf
133
+ end
134
+ module Not
135
+ end
136
+
137
+ module SchemaArray
138
+ end
139
+ module NonNegativeInteger
140
+ end
141
+ module NonNegativeIntegerDefault0
142
+ end
143
+ module SimpleType
144
+ end
145
+ module StringArray
146
+ end
147
+
148
+ Example = Examples.items
149
+ Dependencies::Dependency = Dependencies.additionalProperties
150
+ Type::Array = Type.anyOf[1]
151
+ NonNegativeIntegerDefault0::Default0 = NonNegativeIntegerDefault0.allOf[1]
152
+ StringItem = StringArray.items
153
+
154
+ module Example
155
+ end
156
+ module Dependencies::Dependency
157
+ end
158
+ module Type::Array
159
+ end
160
+ module NonNegativeIntegerDefault0::Default0
161
+ end
162
+ module StringItem
163
+ end
164
+ end
165
+
166
+ JSONSchemaOrgDraft06 = JSONSchemaDraft06
167
+
168
+ # @deprecated after v0.7.0, alias of {JSONSchemaDraft06}
169
+ module JSONSchemaOrgDraft06
13
170
  end
14
171
  end
@@ -2,13 +2,197 @@
2
2
 
3
3
  module JSI
4
4
  metaschema_document = ::JSON.parse(SCHEMAS_PATH.join('json-schema.org/draft-07/schema.json').read)
5
- JSONSchemaOrgDraft07 = MetaschemaNode.new(metaschema_document,
5
+ JSONSchemaDraft07 = JSI.new_metaschema_module(metaschema_document,
6
6
  schema_implementation_modules: [JSI::Schema::Draft07],
7
- ).jsi_schema_module
7
+ )
8
8
 
9
9
  # the JSI schema module for `http://json-schema.org/draft-07/schema`
10
- module JSONSchemaOrgDraft07
11
- # @!parse extend JSI::DescribesSchemaModule
10
+ module JSONSchemaDraft07
11
+ # @!parse extend JSI::SchemaModule::MetaSchemaModule
12
12
  # @!parse include JSI::Schema::Draft07
13
+
14
+
15
+ Id = properties['$id']
16
+ Xschema = properties['$schema']
17
+ Ref = properties['$ref']
18
+ Comment = properties['$comment']
19
+ Title = properties['title']
20
+ Description = properties['description']
21
+ Default = properties['default']
22
+ ReadOnly = properties['readOnly']
23
+ Examples = properties['examples']
24
+ MultipleOf = properties['multipleOf']
25
+ Maximum = properties['maximum']
26
+ ExclusiveMaximum = properties['exclusiveMaximum']
27
+ Minimum = properties['minimum']
28
+ ExclusiveMinimum = properties['exclusiveMinimum']
29
+ MaxLength = properties['maxLength']
30
+ MinLength = properties['minLength']
31
+ Pattern = properties['pattern']
32
+ AdditionalItems = properties['additionalItems']
33
+ Items = properties['items']
34
+ MaxItems = properties['maxItems']
35
+ MinItems = properties['minItems']
36
+ UniqueItems = properties['uniqueItems']
37
+ Contains = properties['contains']
38
+ MaxProperties = properties['maxProperties']
39
+ MinProperties = properties['minProperties']
40
+ Required = properties['required']
41
+ AdditionalProperties = properties['additionalProperties']
42
+ Definitions = properties['definitions']
43
+ Properties = properties['properties']
44
+ PatternProperties = properties['patternProperties']
45
+ Dependencies = properties['dependencies']
46
+ PropertyNames = properties['propertyNames']
47
+ Const = properties['const']
48
+ Enum = properties['enum']
49
+ Type = properties['type']
50
+ Format = properties['format']
51
+ ContentMediaType = properties['contentMediaType']
52
+ ContentEncoding = properties['contentEncoding']
53
+ If = properties['if']
54
+ Then = properties['then']
55
+ Else = properties['else']
56
+ AllOf = properties['allOf']
57
+ AnyOf = properties['anyOf']
58
+ OneOf = properties['oneOf']
59
+ Not = properties['not']
60
+
61
+ SchemaArray = definitions['schemaArray']
62
+ NonNegativeInteger = definitions['nonNegativeInteger']
63
+ NonNegativeIntegerDefault0 = definitions['nonNegativeIntegerDefault0']
64
+ SimpleType = definitions['simpleTypes']
65
+ StringArray = definitions['stringArray']
66
+
67
+ module Id
68
+ end
69
+ module Xschema
70
+ end
71
+ module Ref
72
+ end
73
+ module Comment
74
+ end
75
+ module Title
76
+ end
77
+ module Description
78
+ end
79
+ module Default
80
+ end
81
+ module ReadOnly
82
+ end
83
+ module Examples
84
+ end
85
+ module MultipleOf
86
+ end
87
+ module Maximum
88
+ end
89
+ module ExclusiveMaximum
90
+ end
91
+ module Minimum
92
+ end
93
+ module ExclusiveMinimum
94
+ end
95
+ module MaxLength
96
+ end
97
+ module MinLength
98
+ end
99
+ module Pattern
100
+ end
101
+ module AdditionalItems
102
+ end
103
+ module Items
104
+ end
105
+ module MaxItems
106
+ end
107
+ module MinItems
108
+ end
109
+ module UniqueItems
110
+ end
111
+ module Contains
112
+ end
113
+ module MaxProperties
114
+ end
115
+ module MinProperties
116
+ end
117
+ module Required
118
+ end
119
+ module AdditionalProperties
120
+ end
121
+ module Definitions
122
+ end
123
+ module Properties
124
+ end
125
+ module PatternProperties
126
+ end
127
+ module Dependencies
128
+ end
129
+ module PropertyNames
130
+ end
131
+ module Const
132
+ end
133
+ module Enum
134
+ end
135
+ module Type
136
+ end
137
+ module Format
138
+ end
139
+ module ContentMediaType
140
+ end
141
+ module ContentEncoding
142
+ end
143
+ module If
144
+ end
145
+ module Then
146
+ end
147
+ module Else
148
+ end
149
+ module AllOf
150
+ end
151
+ module AnyOf
152
+ end
153
+ module OneOf
154
+ end
155
+ module Not
156
+ end
157
+
158
+ module SchemaArray
159
+ end
160
+ module NonNegativeInteger
161
+ end
162
+ module NonNegativeIntegerDefault0
163
+ end
164
+ module SimpleType
165
+ end
166
+ module StringArray
167
+ end
168
+
169
+ Example = Examples.items
170
+ PatternPropertyPattern = PatternProperties.propertyNames
171
+ Dependencies::Dependency = Dependencies.additionalProperties
172
+ Enum::Item = Enum.items
173
+ Type::Array = Type.anyOf[1]
174
+ NonNegativeIntegerDefault0::Default0 = NonNegativeIntegerDefault0.allOf[1]
175
+ StringItem = StringArray.items
176
+
177
+ module Example
178
+ end
179
+ module PatternPropertyPattern
180
+ end
181
+ module Dependencies::Dependency
182
+ end
183
+ module Enum::Item
184
+ end
185
+ module Type::Array
186
+ end
187
+ module NonNegativeIntegerDefault0::Default0
188
+ end
189
+ module StringItem
190
+ end
191
+ end
192
+
193
+ JSONSchemaOrgDraft07 = JSONSchemaDraft07
194
+
195
+ # @deprecated after v0.7.0, alias of {JSONSchemaDraft07}
196
+ module JSONSchemaOrgDraft07
13
197
  end
14
198
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-10 00:00:00.000000000 Z
11
+ date: 2024-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bigdecimal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: JSI offers an Object-Oriented representation for JSON data using JSON
28
42
  Schemas
29
43
  email:
@@ -39,9 +53,9 @@ files:
39
53
  - jsi.gemspec
40
54
  - lib/jsi.rb
41
55
  - lib/jsi/base.rb
56
+ - lib/jsi/base/mutability.rb
42
57
  - lib/jsi/base/node.rb
43
58
  - lib/jsi/jsi_coder.rb
44
- - lib/jsi/metaschema.rb
45
59
  - lib/jsi/metaschema_node.rb
46
60
  - lib/jsi/metaschema_node/bootstrap_schema.rb
47
61
  - lib/jsi/ptr.rb
@@ -75,7 +89,6 @@ files:
75
89
  - lib/jsi/schema/validation/array.rb
76
90
  - lib/jsi/schema/validation/const.rb
77
91
  - lib/jsi/schema/validation/contains.rb
78
- - lib/jsi/schema/validation/core.rb
79
92
  - lib/jsi/schema/validation/dependencies.rb
80
93
  - lib/jsi/schema/validation/draft04.rb
81
94
  - lib/jsi/schema/validation/draft04/minmax.rb
@@ -102,6 +115,7 @@ files:
102
115
  - lib/jsi/util.rb
103
116
  - lib/jsi/util/private.rb
104
117
  - lib/jsi/util/private/attr_struct.rb
118
+ - lib/jsi/util/private/memo_map.rb
105
119
  - lib/jsi/util/typelike.rb
106
120
  - lib/jsi/validation.rb
107
121
  - lib/jsi/validation/error.rb
@@ -133,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
147
  - !ruby/object:Gem::Version
134
148
  version: '0'
135
149
  requirements: []
136
- rubygems_version: 3.1.6
150
+ rubygems_version: 3.4.10
137
151
  signing_key:
138
152
  specification_version: 4
139
153
  summary: 'JSI: JSON Schema Instantiation'
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module JSI
4
- module Metaschema
5
- end
6
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module JSI
4
- module Schema::Validation::Core
5
- # validates the given instance against this schema
6
- #
7
- # @private
8
- # @param instance_ptr [JSI::Ptr] a pointer to the instance to validate against the schema, in the instance_document
9
- # @param instance_document [#to_hash, #to_ary, Object] document containing the instance instance_ptr pointer points to
10
- # @param validate_only [Boolean] whether to return a full schema validation result or a simple, validation-only result
11
- # @param visited_refs [Enumerable<JSI::Schema::Ref>]
12
- # @return [JSI::Validation::Result]
13
- def internal_validate_instance(instance_ptr, instance_document, validate_only: false, visited_refs: [])
14
- if validate_only
15
- result = JSI::Validation::VALID
16
- else
17
- result = JSI::Validation::FullResult.new
18
- end
19
- result_builder = result.builder(self, instance_ptr, instance_document, validate_only, visited_refs)
20
-
21
- catch(:jsi_validation_result) do
22
- # note: true/false are not valid as schemas in draft 4; they are only values of
23
- # additionalProperties / additionalItems. since their behavior is undefined, though,
24
- # it's fine for them to behave the same as boolean schemas in later drafts.
25
- # I don't care about draft 4 to implement a different structuring for that.
26
- if schema_content == true
27
- # noop
28
- elsif schema_content == false
29
- result_builder.validate(false, 'instance is not valid against `false` schema')
30
- elsif schema_content.respond_to?(:to_hash)
31
- internal_validate_keywords(result_builder)
32
- else
33
- result_builder.schema_error('schema is not a boolean or a JSON object')
34
- end
35
- result
36
- end.freeze
37
- end
38
- end
39
- end