jsonschema_rs 0.42.0-aarch64-linux → 0.42.2-aarch64-linux
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +83 -29
- data/lib/jsonschema/3.2/jsonschema_rb.so +0 -0
- data/lib/jsonschema/3.3/jsonschema_rb.so +0 -0
- data/lib/jsonschema/3.4/jsonschema_rb.so +0 -0
- data/lib/jsonschema/4.0/jsonschema_rb.so +0 -0
- data/lib/jsonschema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 021caf2f915f392daf60de381ba97591416e2bbdf1a62373d3d9290b88f8e095
|
|
4
|
+
data.tar.gz: 918d7d998823717abcce53e3b08ced90567025a535d5888332d3795dddfa4419
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f76bc26b78ad1e70ff97ef1164c0b9f88001f010660c8cb7da90e5dc997fb0d85a503002a57bff010dee5fc98b7deb0f3446f71a71b83a1b1ddc32983d140b4f
|
|
7
|
+
data.tar.gz: 4634c084b338805ca2f90174c94c55dbf3bf23340c25704e02802de70db302d4c1a2521008eff8756d1228568bd77e4a844408032177b26fb26ecc0d307e2368
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.42.2] - 2026-02-26
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Custom keyword validation exceptions are now chained to the resulting `ValidationError` via `cause`, preserving the original exception class and message.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- SWAR digit parser accepted bytes `:`–`?` (0x3A–0x3F) as valid digits during `date`, `time`, and `date-time` format validation, potentially allowing malformed values to pass.
|
|
14
|
+
|
|
15
|
+
### Performance
|
|
16
|
+
|
|
17
|
+
- Extend `pattern` prefix optimization to handle escaped slashes (`^\/`) and exact-match patterns (`^\$ref$`).
|
|
18
|
+
- Specialize `enum` for cases when all variants are strings.
|
|
19
|
+
|
|
20
|
+
## [0.42.1] - 2026-02-17
|
|
21
|
+
|
|
22
|
+
### Performance
|
|
23
|
+
|
|
24
|
+
- Reduce dynamic dispatch overhead for non-recursive `$ref` resolution.
|
|
25
|
+
- Cache ECMA regex transformations during `format: "regex"` validation.
|
|
26
|
+
|
|
5
27
|
## 0.42.0 - 2026-02-15
|
|
6
28
|
|
|
7
29
|
- Initial public release
|
|
8
30
|
|
|
31
|
+
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.42.2...HEAD
|
|
32
|
+
[0.42.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.42.1...ruby-v0.42.2
|
|
33
|
+
[0.42.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.42.0...ruby-v0.42.1
|
data/README.md
CHANGED
|
@@ -36,8 +36,8 @@ validator.valid?(instance) # => true
|
|
|
36
36
|
|
|
37
37
|
# Structured output (JSON Schema Output v1)
|
|
38
38
|
evaluation = validator.evaluate(instance)
|
|
39
|
-
evaluation.
|
|
40
|
-
puts "
|
|
39
|
+
evaluation.errors.each do |err|
|
|
40
|
+
puts "Error at #{err[:instanceLocation]}: #{err[:error]}"
|
|
41
41
|
end
|
|
42
42
|
```
|
|
43
43
|
|
|
@@ -86,7 +86,7 @@ If no pre-built gem is available for your platform, it will be compiled from sou
|
|
|
86
86
|
### Reusable validators
|
|
87
87
|
|
|
88
88
|
For validating multiple instances against the same schema, create a reusable validator.
|
|
89
|
-
`validator_for` automatically detects the draft version from the `$schema` keyword in the schema:
|
|
89
|
+
`validator_for` automatically detects the draft version from the `$schema` keyword in the schema and falls back to Draft 2020-12:
|
|
90
90
|
|
|
91
91
|
```ruby
|
|
92
92
|
validator = JSONSchema.validator_for({
|
|
@@ -147,9 +147,20 @@ Each custom keyword class must implement:
|
|
|
147
147
|
- `initialize(parent_schema, value, schema_path)` - called during schema compilation
|
|
148
148
|
- `validate(instance)` - raise on failure, return normally on success
|
|
149
149
|
|
|
150
|
+
When `validate` raises, the original exception is preserved as the `cause` of the `ValidationError`, so callers can inspect it:
|
|
151
|
+
|
|
152
|
+
```ruby
|
|
153
|
+
begin
|
|
154
|
+
validator.validate!(3)
|
|
155
|
+
rescue JSONSchema::ValidationError => e
|
|
156
|
+
puts e.cause.class # => RuntimeError
|
|
157
|
+
puts e.cause.message # => "3 is not even"
|
|
158
|
+
end
|
|
159
|
+
```
|
|
160
|
+
|
|
150
161
|
### Structured evaluation output
|
|
151
162
|
|
|
152
|
-
When you need more than a boolean result, use the `evaluate` API to access the JSON Schema Output v1 formats:
|
|
163
|
+
When you need more than a boolean result, use the `evaluate` API to access the [JSON Schema Output v1](https://json-schema.org/draft/2020-12/json-schema-core#name-output-formatting) formats:
|
|
153
164
|
|
|
154
165
|
```ruby
|
|
155
166
|
schema = {
|
|
@@ -165,34 +176,79 @@ validator = JSONSchema.validator_for(schema)
|
|
|
165
176
|
evaluation = validator.evaluate({ "age" => "not_an_integer" })
|
|
166
177
|
|
|
167
178
|
evaluation.valid? # => false
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Flag output** — simplest, just valid/invalid:
|
|
168
182
|
|
|
169
|
-
|
|
183
|
+
```ruby
|
|
170
184
|
evaluation.flag
|
|
171
|
-
# => {
|
|
185
|
+
# => {valid: false}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**List output** — flat list of all evaluation nodes:
|
|
172
189
|
|
|
173
|
-
|
|
190
|
+
```ruby
|
|
174
191
|
evaluation.list
|
|
175
|
-
# => {
|
|
176
|
-
#
|
|
177
|
-
#
|
|
178
|
-
#
|
|
179
|
-
#
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
#
|
|
192
|
+
# => {valid: false,
|
|
193
|
+
# details: [
|
|
194
|
+
# {valid: false, evaluationPath: "", schemaLocation: "", instanceLocation: ""},
|
|
195
|
+
# {valid: true, evaluationPath: "/type", schemaLocation: "/type", instanceLocation: ""},
|
|
196
|
+
# {valid: false, evaluationPath: "/required", schemaLocation: "/required",
|
|
197
|
+
# instanceLocation: "",
|
|
198
|
+
# errors: {"required" => "\"name\" is a required property"}},
|
|
199
|
+
# {valid: false, evaluationPath: "/properties", schemaLocation: "/properties",
|
|
200
|
+
# instanceLocation: "", droppedAnnotations: ["age"]},
|
|
201
|
+
# {valid: false, evaluationPath: "/properties/age", schemaLocation: "/properties/age",
|
|
202
|
+
# instanceLocation: "/age"},
|
|
203
|
+
# {valid: false, evaluationPath: "/properties/age/type",
|
|
204
|
+
# schemaLocation: "/properties/age/type", instanceLocation: "/age",
|
|
205
|
+
# errors: {"type" => "\"not_an_integer\" is not of type \"integer\""}}
|
|
206
|
+
# ]}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Hierarchical output** — nested tree following schema structure:
|
|
210
|
+
|
|
211
|
+
```ruby
|
|
183
212
|
evaluation.hierarchical
|
|
184
|
-
# => {
|
|
185
|
-
#
|
|
213
|
+
# => {valid: false, evaluationPath: "", schemaLocation: "", instanceLocation: "",
|
|
214
|
+
# details: [
|
|
215
|
+
# {valid: true, evaluationPath: "/type", schemaLocation: "/type", instanceLocation: ""},
|
|
216
|
+
# {valid: false, evaluationPath: "/required", schemaLocation: "/required",
|
|
217
|
+
# instanceLocation: "",
|
|
218
|
+
# errors: {"required" => "\"name\" is a required property"}},
|
|
219
|
+
# {valid: false, evaluationPath: "/properties", schemaLocation: "/properties",
|
|
220
|
+
# instanceLocation: "", droppedAnnotations: ["age"],
|
|
221
|
+
# details: [
|
|
222
|
+
# {valid: false, evaluationPath: "/properties/age",
|
|
223
|
+
# schemaLocation: "/properties/age", instanceLocation: "/age",
|
|
224
|
+
# details: [
|
|
225
|
+
# {valid: false, evaluationPath: "/properties/age/type",
|
|
226
|
+
# schemaLocation: "/properties/age/type", instanceLocation: "/age",
|
|
227
|
+
# errors: {"type" => "\"not_an_integer\" is not of type \"integer\""}}
|
|
228
|
+
# ]}
|
|
229
|
+
# ]}
|
|
230
|
+
# ]}
|
|
231
|
+
```
|
|
186
232
|
|
|
187
|
-
|
|
233
|
+
**Collected errors** — flat list of all errors across evaluation nodes:
|
|
234
|
+
|
|
235
|
+
```ruby
|
|
188
236
|
evaluation.errors
|
|
189
|
-
# => [{
|
|
190
|
-
#
|
|
237
|
+
# => [{schemaLocation: "/required", absoluteKeywordLocation: nil,
|
|
238
|
+
# instanceLocation: "", error: "\"name\" is a required property"},
|
|
239
|
+
# {schemaLocation: "/properties/age/type", absoluteKeywordLocation: nil,
|
|
240
|
+
# instanceLocation: "/age",
|
|
241
|
+
# error: "\"not_an_integer\" is not of type \"integer\""}]
|
|
242
|
+
```
|
|
191
243
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
244
|
+
**Collected annotations** — flat list of annotations from successfully validated nodes.
|
|
245
|
+
When a node fails validation, its annotations appear as `droppedAnnotations` in the list/hierarchical output instead.
|
|
246
|
+
|
|
247
|
+
```ruby
|
|
248
|
+
valid_eval = validator.evaluate({ "name" => "Alice", "age" => 30 })
|
|
249
|
+
valid_eval.annotations
|
|
250
|
+
# => [{schemaLocation: "/properties", absoluteKeywordLocation: nil,
|
|
251
|
+
# instanceLocation: "", annotations: ["age", "name"]}]
|
|
196
252
|
```
|
|
197
253
|
|
|
198
254
|
## Meta-Schema Validation
|
|
@@ -460,14 +516,12 @@ Valid draft symbols: `:draft4`, `:draft6`, `:draft7`, `:draft201909`, `:draft202
|
|
|
460
516
|
|
|
461
517
|
`jsonschema` is designed for high performance, outperforming other Ruby JSON Schema validators in most scenarios:
|
|
462
518
|
|
|
463
|
-
- **
|
|
464
|
-
- **
|
|
465
|
-
- **7-
|
|
519
|
+
- **28-148x** faster than `json_schemer` for complex schemas and large instances
|
|
520
|
+
- **200-567x** faster than `json-schema` where supported
|
|
521
|
+
- **7-130x** faster than `rj_schema` (RapidJSON/C++)
|
|
466
522
|
|
|
467
523
|
For detailed benchmarks, see our [full performance comparison](https://github.com/Stranger6667/jsonschema/blob/master/crates/jsonschema-rb/BENCHMARKS.md).
|
|
468
524
|
|
|
469
|
-
**Tips:** Reuse validators. Use `valid?` for boolean checks (short-circuits on first error).
|
|
470
|
-
|
|
471
525
|
## Acknowledgements
|
|
472
526
|
|
|
473
527
|
This library draws API design inspiration from the Python [`jsonschema`](https://github.com/python-jsonschema/jsonschema) package. We're grateful to the Python `jsonschema` maintainers and contributors for their pioneering work in JSON Schema validation.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/jsonschema/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsonschema_rs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.42.
|
|
4
|
+
version: 0.42.2
|
|
5
5
|
platform: aarch64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dygalo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|