schemurai 2.1.0 → 2.2.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.
data/sig/schemurai.rbs ADDED
@@ -0,0 +1,157 @@
1
+ module Schemurai
2
+ # A JSON-shaped Ruby value accepted as a schema value or validation instance.
3
+ type json_value =
4
+ nil
5
+ | bool
6
+ | Integer
7
+ | Float
8
+ | String
9
+ | Array[json_value]
10
+ | Hash[String, json_value]
11
+
12
+ # A JSON Schema root.
13
+ type schema = bool | Hash[String, json_value]
14
+
15
+ # External schemas indexed by their absolute URI.
16
+ type schemas = Hash[String, schema]
17
+
18
+ # A resolved evaluator backend.
19
+ type backend = :ruby | :vm
20
+
21
+ # A backend accepted when configuring a validator.
22
+ type backend_selection = backend | :default
23
+
24
+ VERSION: String
25
+
26
+ class Error < StandardError
27
+ end
28
+
29
+ class ResolutionError < Error
30
+ end
31
+
32
+ class UnsupportedFormatError < Error
33
+ end
34
+
35
+ class InvalidSchemaError < Error
36
+ attr_reader result: Result
37
+
38
+ def initialize: (Result result) -> void
39
+ end
40
+
41
+ class ValidationError < Data
42
+ attr_reader keyword: String
43
+ attr_reader instance_path: String
44
+ attr_reader schema_path: String
45
+ attr_reader message: String
46
+
47
+ def self.new: (String keyword, String instance_path, String schema_path, String message) -> ValidationError
48
+ | (keyword: String, instance_path: String, schema_path: String, message: String) -> ValidationError
49
+
50
+ def self.[]: (String keyword, String instance_path, String schema_path, String message) -> ValidationError
51
+ | (keyword: String, instance_path: String, schema_path: String, message: String) -> ValidationError
52
+
53
+ def to_h: () -> {
54
+ keyword: String,
55
+ instance_path: String,
56
+ schema_path: String,
57
+ message: String
58
+ }
59
+ end
60
+
61
+ class Result
62
+ attr_reader errors: Array[ValidationError]
63
+
64
+ def initialize: (Array[ValidationError] errors) -> void
65
+ def valid?: () -> bool
66
+ alias success? valid?
67
+ end
68
+
69
+ interface _Evaluator
70
+ def backend: () -> backend
71
+ def validate: (json_value instance) -> Result
72
+ def valid?: (json_value instance) -> bool
73
+ end
74
+
75
+ class Validator
76
+ def initialize: (_Evaluator evaluator) -> void
77
+ def backend: () -> backend
78
+ def validate: (json_value instance) -> Result
79
+ def valid?: (json_value instance) -> bool
80
+ end
81
+
82
+ class SchemaRegistry
83
+ attr_reader backend: backend
84
+
85
+ def initialize: (
86
+ ?schemas: schemas,
87
+ ?validate_schema: bool,
88
+ ?backend: backend_selection
89
+ ) -> void
90
+
91
+ def validate_schema?: () -> bool
92
+
93
+ def compile: (
94
+ schema schema,
95
+ ?base_uri: String?,
96
+ ?content: bool,
97
+ ?format: bool
98
+ ) -> Validator
99
+
100
+ def validate_schema: (schema schema) -> Result
101
+ def valid_schema?: (schema schema) -> bool
102
+ def make_shareable: () -> self
103
+ def shareable?: () -> bool
104
+
105
+ def validator_for: (
106
+ String uri,
107
+ ?content: bool,
108
+ ?format: bool
109
+ ) -> Validator
110
+ end
111
+
112
+ def self.backend: () -> backend
113
+
114
+ def self.compile: (
115
+ schema schema,
116
+ ?schemas: schemas,
117
+ ?base_uri: String?,
118
+ ?content: bool,
119
+ ?format: bool,
120
+ ?validate_schema: bool,
121
+ ?backend: backend_selection
122
+ ) -> Validator
123
+
124
+ def self.validate_schema: (
125
+ schema schema,
126
+ ?schemas: schemas,
127
+ ?backend: backend_selection
128
+ ) -> Result
129
+
130
+ def self.valid_schema?: (
131
+ schema schema,
132
+ ?schemas: schemas,
133
+ ?backend: backend_selection
134
+ ) -> bool
135
+
136
+ def self.validate: (
137
+ schema schema,
138
+ json_value instance,
139
+ ?schemas: schemas,
140
+ ?base_uri: String?,
141
+ ?content: bool,
142
+ ?format: bool,
143
+ ?validate_schema: bool,
144
+ ?backend: backend_selection
145
+ ) -> Result
146
+
147
+ def self.valid?: (
148
+ schema schema,
149
+ json_value instance,
150
+ ?schemas: schemas,
151
+ ?base_uri: String?,
152
+ ?content: bool,
153
+ ?format: bool,
154
+ ?validate_schema: bool,
155
+ ?backend: backend_selection
156
+ ) -> bool
157
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schemurai
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuya KOHARA (oakcask)
@@ -56,13 +56,14 @@ files:
56
56
  - lib/schemurai/version.rb
57
57
  - lib/schemurai/vm/compiler.rb
58
58
  - lib/schemurai/vm/evaluator.rb
59
+ - sig/schemurai.rbs
59
60
  homepage: https://github.com/oakcask/schemurai
60
61
  licenses:
61
62
  - MIT
62
63
  metadata:
63
64
  homepage_uri: https://github.com/oakcask/schemurai
64
65
  source_code_uri: https://github.com/oakcask/schemurai/tree/main
65
- documentation_uri: https://rubydoc.info/gems/schemurai/2.1.0
66
+ documentation_uri: https://rubydoc.info/gems/schemurai/2.2.0
66
67
  rubygems_mfa_required: 'true'
67
68
  rdoc_options:
68
69
  - "--main"