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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29e5bf1c85875f60a2e1d02f769b203839c377a3d72c63f8ae0aecf3c47ed7b3
4
- data.tar.gz: 30e5f0a7e3e427eb2b1d4f5d34b995cf79c2b3fe06649b1a3d3a804d74f85e1f
3
+ metadata.gz: 021caf2f915f392daf60de381ba97591416e2bbdf1a62373d3d9290b88f8e095
4
+ data.tar.gz: 918d7d998823717abcce53e3b08ced90567025a535d5888332d3795dddfa4419
5
5
  SHA512:
6
- metadata.gz: 226a01d9b43a84e8e29cd2c373ff133a79fb0c9b7ff151d760040b5b8314a22efb873748f95e5a72afdcfd980099cedcdc8aed3004379d8920248912876c0b13
7
- data.tar.gz: 921ca6bae055f06fbd00f9e680102b67ff69f87ee8b69e7f1cbb29235e02917b894b652a60676429e65831062259f063eb07968eef72356d255f48521dfe9a5c
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.annotations.each do |ann|
40
- puts "Annotation at #{ann[:schemaLocation]}: #{ann[:annotations]}"
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
- # Flag output (simplest)
183
+ ```ruby
170
184
  evaluation.flag
171
- # => { "valid" => false }
185
+ # => {valid: false}
186
+ ```
187
+
188
+ **List output** — flat list of all evaluation nodes:
172
189
 
173
- # List output (flat)
190
+ ```ruby
174
191
  evaluation.list
175
- # => { "valid" => false, "details" => [
176
- # { "valid" => false, "evaluationPath" => "", "instanceLocation" => "", "schemaLocation" => "" },
177
- # { "valid" => false, "evaluationPath" => "/required", "instanceLocation" => "", "schemaLocation" => "/required",
178
- # "errors" => { "required" => "\"name\" is a required property" } },
179
- # ...
180
- # ] }
181
-
182
- # Hierarchical output (nested tree following schema structure)
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
- # => { "valid" => false, "evaluationPath" => "", "instanceLocation" => "", "schemaLocation" => "",
185
- # "details" => [ ... ] }
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
- # Collected errors across all nodes
233
+ **Collected errors** flat list of all errors across evaluation nodes:
234
+
235
+ ```ruby
188
236
  evaluation.errors
189
- # => [{ "schemaLocation" => "/required", "instanceLocation" => "",
190
- # "absoluteKeywordLocation" => nil, "error" => "\"name\" is a required property" }, ...]
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
- # Collected annotations
193
- evaluation.annotations
194
- # => [{ "schemaLocation" => "/properties", "instanceLocation" => "",
195
- # "absoluteKeywordLocation" => nil, "annotations" => ["age"] }]
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
- - **26-141x** faster than `json_schemer` for complex schemas and large instances
464
- - **174-535x** faster than `json-schema` where supported
465
- - **7-125x** faster than `rj_schema` (RapidJSON/C++)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.42.0"
4
+ VERSION = "0.42.2"
5
5
  end
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2026-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal