jsonschema_rs 0.61.2 → 0.63.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6167fe592d67760e2cbf0e65ce166b019e901c25d6438dd39f9b473d9248179
4
- data.tar.gz: 5328baa6255254689d6a3e994f86e0aeca7c054fbe536068b1ac75e01b1b7e25
3
+ metadata.gz: 11341f312f2370a4aad4177a118b755a93c5c5125b9f16909a3789ac4d32b723
4
+ data.tar.gz: 459de3dbe56f54449b438e4ba989e1a5210c25cbcd79592c907861feae30538d
5
5
  SHA512:
6
- metadata.gz: ba73f7863f1a404234c5aa2f0156f249d27c5dbbac1e205f899162d98cb54f211c3d5625ea64de4434616bb6efccd57e73e03e10415df8a028f7001931a47b57
7
- data.tar.gz: ae1e20516dc325b2866f9ff8ad8e628c3eadea7082bf2d97b39d24cf0b6d4f138ee2d26a9939485d494143ca71f9e9847b68ba897da79addbb1a605d43436441
6
+ metadata.gz: 2a1321a9cf38d77fe449faf466b01272c37e39072e970c009fcc9eff7d88de8df13db108dd73fb822d2d03b01a7e7a3b25d791c513ee718579255a35214f89eb
7
+ data.tar.gz: 20c4f5cbbfe0baf5a7a1a1c6172426b04c5bac79c5572e993ff93d7ead9453766c4996a89481c52395fc245d1ff392b4648d9db5daf81d082be6e826a7eca773
data/CHANGELOG.md CHANGED
@@ -2,6 +2,113 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.63.0] - 2026-11-22
6
+
7
+ ### Added
8
+
9
+ - `JsonTextValidator`, validating instances given as JSON text without building Ruby objects for them.
10
+ - `JSONSchema.number_format`, a custom `format` check that reads numbers.
11
+
12
+ ### Fixed
13
+
14
+ - `$ref` to a bundled meta-schema of a draft other than the schema's own, such as `https://json-schema.org/draft/2020-12/schema` from a Draft 7 schema, failing to resolve.
15
+ - `$ref` to a `json-schema.org` URI with no bundled meta-schema, such as `http://json-schema.org/draft-03/schema#`, never retrieved.
16
+ - Error messages for an empty `enum` ending after "is not one of" instead of naming the empty `enum`.
17
+ - `HttpOptions.new(ca_cert: ...)` accepting a file without certificates.
18
+ - Draft 4 schemas with an empty `enum`, or one with equal members such as `[0, 0.0]`, passing the meta-schema check.
19
+ - `HttpOptions.new(ca_cert: ...)` reporting invalid PEM as an HTTP client build error instead of a certificate parse error that names the file.
20
+ - Custom keyword `iter_errors` returning a non-exception producing a message prefixed with `RuntimeError: ` and no `cause`.
21
+ - Named backreferences such as `(?<n>x)\k<n>` failing to build in `pattern`, `patternProperties` and `propertyNames`.
22
+ - Patterns with a backreference or lookaround matching `\d`, `\w`, `\s` and `.` beyond ECMA 262, and rejecting a backreference to a group that did not match.
23
+
24
+ ## [0.62.0] - 2026-11-21
25
+
26
+ ### Added
27
+
28
+ - `syntax: :engine` on `RegexOptions` and `FancyRegexOptions` to match `pattern` and `patternProperties` in the regex engine's own syntax, without the ECMA 262 translation. [#1895](https://github.com/Stranger6667/jsonschema/issues/1895)
29
+ - `Resolver#lookup_dynamic_ref` to resolve a `$dynamicRef` through the dynamic scope. [#1923](https://github.com/Stranger6667/jsonschema/issues/1923)
30
+ - `minContains` and `maxContains` error kinds.
31
+
32
+ ### Changed
33
+
34
+ - Non-string keys of a root `Hash` raising only when validation reads them, like keys of nested ones, instead of on every call.
35
+
36
+ ### Fixed
37
+
38
+ #### References and `$schema`
39
+
40
+ - `$ref` to a `$dynamicAnchor` resolving through the dynamic scope like `$dynamicRef`, to an outer `$dynamicAnchor` of the same name instead of the schema it names. [#1923](https://github.com/Stranger6667/jsonschema/issues/1923)
41
+ - `$dynamicRef` in a `$ref` cycle resolving as on the first pass through the cycle, ignoring a `$dynamicAnchor` that a later pass brings into the dynamic scope.
42
+ - `$recursiveRef` stopping at a resource without `$recursiveAnchor: true` in the dynamic scope instead of resolving to the outermost resource with `$recursiveAnchor: true`.
43
+ - `$dynamicRef` landing in another resource leaving the resource that holds it out of the dynamic scope.
44
+ - `Validator` results depending on how references name a schema that a `$ref` cycle passes through, such as `cycle` and `#` inside it.
45
+ - `Validator` results for a schema that references itself with `#` differing from the same schema reached through a `$ref`, such as `{"not": {"$ref": "#"}}` rejecting every instance.
46
+ - A subschema's own `$schema` ignored through a `$ref` and in the meta-schema check, which could fail or pass it against the wrong draft.
47
+ - `validator_map_for` entries accepting every value for a subschema in Draft 2019-09 or later under a Draft 7 or earlier root.
48
+ - `validator_map_for` entries below the root differing from the same subschema reached through a `$ref`.
49
+ - `$recursiveRef` and `$dynamicRef` inside a subschema with its own `$id` leaving the resource that holds it out of the dynamic scope when that subschema is reached inline or through a JSON Pointer `$ref`.
50
+
51
+ #### `evaluate` output
52
+
53
+ - Schemas with both `minLength` and `maxLength` leaving out the `maxLength` unit for accepted strings, and nesting it under a failing `minLength` unit for longer ones.
54
+ - Messages for a `type` that lists several types differing from `validate`, as `is not of types (null, string)` instead of `is not of types "null", "string"`.
55
+ - `properties` or `patternProperties` beside `additionalProperties` reporting their subschemas inside the `additionalProperties` unit instead of in units of their own.
56
+ - One `required` name beside `properties` and `additionalProperties: false` reporting the name inside the `additionalProperties` unit, and only when missing.
57
+ - `additionalProperties: false` reporting one error for the whole object instead of a failing unit for each extra member.
58
+ - Two `required` names beside `properties` reporting them inside the `properties` unit, failing it, and only when missing.
59
+ - `propertyNames: false` reporting one error for the whole object instead of a failing unit for each name.
60
+ - `dependentRequired` and the array form of `dependencies` reporting missing names in a nested unit at a schema location that does not exist.
61
+ - Array-form `items` and `additionalItems` missing their annotations, and `additionalItems` reporting the extra items in one error instead of a unit for each.
62
+ - `contains` beside `minContains` or `maxContains` missing the matching items and their indices, and locating the subschema at the bound keyword instead of at `contains`.
63
+ - `then` and `else` reported inside the `if` unit instead of in units of their own.
64
+ - `oneOf` with more than one valid subschema reporting a different message than `validate`.
65
+ - `contains` annotating an instance that is not an array.
66
+ - Locating a `$ref` target at the URI its document was registered under instead of the `$id` that document declares.
67
+
68
+ #### Error locations and messages
69
+
70
+ - Evaluation paths of custom keyword errors leaving out the `$ref` the keyword was reached through.
71
+ - Evaluation paths below a subschema reached both inline and through a `$ref` taking part of their path from the other route.
72
+ - Error messages for `minContains` and `maxContains` claiming that no item is valid under the `contains` subschema.
73
+ - Evaluation paths of `propertyNames` errors leaving out a `$ref` inside `propertyNames`.
74
+ - `absolute_keyword_location` of errors for names missing under `dependentRequired` or `dependencies` pointing to a schema location that does not exist.
75
+ - `absolute_keyword_location` of errors from a resource without a base URI, such as one registered under a `json-schema:///` URI, naming the `$ref` or other keyword that reached it from a resource with one, instead of being absent.
76
+ - `propertyNames` errors reporting `propertyNames` as their absolute keyword location instead of the keyword that rejected the name.
77
+
78
+ #### Keywords
79
+
80
+ - `unevaluatedItems` in Draft 2019-09 treating items matched by `contains` as evaluated.
81
+ - `contentEncoding` going unchecked in Draft 7 beside an unsupported `contentMediaType`.
82
+ - `contentEncoding` and `contentMediaType` asserted in Draft 6, which does not define them.
83
+ - `unevaluatedProperties` and `unevaluatedItems` errors and `evaluate` output counting members as evaluated by a subschema that fails, such as a `$ref` target.
84
+ - `multipleOf` with an integer divisor above 2^53 accepting numbers too small for `Float`, such as `BigDecimal("1e-400")`.
85
+ - `pattern` with a large bounded count the regex engine matches, such as `^x?.{0,404600}$`, failing with a regex engine error on the empty string when the size limit was raised to compile it.
86
+
87
+ #### `dereference`
88
+
89
+ - `dereference` dropping siblings of `$ref` in Draft 2019-09 and later when the referenced schema defines the same keyword with another value or is a boolean.
90
+ - `dereference` merging siblings of `$ref` into the referenced schema in Draft 2019-09 and later when they change what its keywords accept, such as `properties` beside `additionalProperties`.
91
+ - `dereference` keeping siblings of `$ref` that Draft 4, 6 and 7 ignore, such as `minimum` or `$id`.
92
+
93
+ ### Performance
94
+
95
+ #### Building validators
96
+
97
+ - Fewer allocations per subschema when building a validator.
98
+ - Faster validator builds for valid schemas, which skip collecting meta-schema errors.
99
+
100
+ #### Validation
101
+
102
+ - Lower cost of collecting errors over the valid parts of an instance.
103
+ - Fewer allocations in `evaluate` for arrays, with every `items` and `additionalItems` annotation sharing one value.
104
+ - Lower cost of `evaluate` for arrays whose `items` is a single `type`, such as `{"type": "number"}`, with consecutive accepted items recorded together instead of as output units per item.
105
+ - `Hash` instances with up to 16 members read without copying them into a Ruby array on the first walk, and the copy kept for repeated walks read and written in place.
106
+ - `Hash` member snapshots built in place and filled without a GC write barrier per member.
107
+ - `pattern` and `patternProperties` with alternations of anchored sequences, such as `^[1-5](?:[0-9]{2}|XX)$`, matched in one pass without a regex engine.
108
+ - `unevaluatedProperties` matching names against sequence-shaped `patternProperties`, such as `^[a-z0-9-]+$` or `^[1-5](?:[0-9]{2}|XX)$`, without a regex engine.
109
+ - `properties` and a sibling `unevaluatedProperties` checked in one pass over the object by `is_valid`.
110
+ - `pattern` and `patternProperties` with fixed-length optional groups, exactly repeated groups, a leading group of alternatives, or a run of varying length after fixed characters, such as `^[a-z][a-z0-9-_]{1,63}$`, matched without a regex engine.
111
+
5
112
  ## [0.61.2] - 2026-11-12
6
113
 
7
114
  ### Fixed
@@ -766,7 +873,9 @@
766
873
 
767
874
  - Initial public release
768
875
 
769
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.2...HEAD
876
+ [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.63.0...HEAD
877
+ [0.63.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.62.0...ruby-v0.63.0
878
+ [0.62.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.2...ruby-v0.62.0
770
879
  [0.61.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.1...ruby-v0.61.2
771
880
  [0.61.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.0...ruby-v0.61.1
772
881
  [0.61.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.60.2...ruby-v0.61.0
data/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.61.2"
3
+ version = "0.63.0"
4
4
  edition = "2021"
5
5
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
6
6
  license = "MIT"
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  strum = "0.28.0"
17
- jsonschema = { version = "0.61.2", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna"] }
17
+ jsonschema = { version = "0.63.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna", "json-text"] }
18
18
  magnus = { version = "0.9", features = ["rb-sys"] }
19
19
  rb-sys = "0.9"
20
20
  serde = { workspace = true }
data/MIGRATION.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Quick Reference
4
4
 
5
- | json_schemer | jsonschema |
5
+ | json_schemer | jsonschema_rs |
6
6
  |---|---|
7
7
  | `JSONSchemer.schema(s)` | `JSONSchema.validator_for(s)` |
8
8
  | `JSONSchemer.schema(s, meta_schema: 'draft7')` | `JSONSchema::Draft7Validator.new(s)` |
@@ -18,18 +18,16 @@
18
18
  | `ref_resolver: proc` | `retriever: proc` |
19
19
  | `format: true` | `validate_formats: true` |
20
20
 
21
- Draft-specific validators are also available: `JSONSchema::Draft7Validator.new(schema)`
22
-
23
21
  ## What Stays the Same
24
22
 
25
23
  - JSON Schema documents work as-is
26
24
  - `valid?` and `validate!` method names
27
- - Custom format validators via `formats:` with the same proc syntax
25
+ - Custom format validators via `formats:`, as procs that take the string
28
26
  - One-off validation: `JSONSchema.valid?(schema, data)`
29
27
 
30
28
  ## Error Objects
31
29
 
32
- json_schemer returns hashes, jsonschema returns `ValidationError` objects:
30
+ json_schemer returns hashes, jsonschema_rs returns `ValidationError` objects:
33
31
 
34
32
  ```ruby
35
33
  # json_schemer
@@ -38,16 +36,16 @@ error["schema_pointer"] # => "/properties/foo/minimum"
38
36
  error["type"] # => "minimum"
39
37
  error["error"] # => "value is less than 10"
40
38
 
41
- # jsonschema
39
+ # jsonschema_rs
42
40
  error.instance_path # => ["foo", "bar"]
43
41
  error.instance_path_pointer # => "/foo/bar" (same format as data_pointer)
44
42
  error.schema_path # => ["properties", "foo", "minimum"]
45
43
  error.schema_path_pointer # => "/properties/foo/minimum"
46
44
  error.kind.name # => "minimum"
47
- error.message # => "value is less than 10"
45
+ error.message # => "5 is less than the minimum of 10"
48
46
 
49
47
  # Need a hash? Use to_h on error kind
50
- error.kind.to_h # => { "name" => "minimum", "value" => { "limit" => 10 } }
48
+ error.kind.to_h # => { name: "minimum", value: { limit: 10 } }
51
49
  ```
52
50
 
53
51
  ## Reference Resolution
@@ -56,10 +54,10 @@ error.kind.to_h # => { "name" => "minimum", "value" => { "limit" => 10 }
56
54
  # json_schemer
57
55
  JSONSchemer.schema(schema, ref_resolver: refs.to_proc)
58
56
 
59
- # jsonschema — retriever
57
+ # jsonschema_rs — retriever
60
58
  JSONSchema.validator_for(schema, retriever: ->(uri) { fetch_schema(uri) })
61
59
 
62
- # jsonschema — registry
60
+ # jsonschema_rs — registry
63
61
  registry = JSONSchema::Registry.new([["http://example.com/s", sub_schema]])
64
62
  JSONSchema.validator_for(schema, registry: registry)
65
63
  ```
@@ -70,11 +68,11 @@ JSONSchema.validator_for(schema, registry: registry)
70
68
  - **Custom keywords** — extend JSON Schema with domain-specific validation rules
71
69
  - **Error masking** — hide sensitive data in error messages with `mask:`
72
70
  - **Regex engine configuration** — choose between fancy-regex (default) and linear-time regex
73
- - **Email validation options** — fine-grained control over email format validation
71
+ - **Email validation options** — TLD, IP-literal, display-name and domain-segment rules for `format: email`
74
72
 
75
73
  ## Not Supported
76
74
 
77
- - `insert_property_defaults` — jsonschema is a validator, not a data transformer
75
+ - `insert_property_defaults` — jsonschema_rs is a validator, not a data transformer
78
76
  - OpenAPI document parsing — use a dedicated OpenAPI library
79
77
 
80
78
  ## Migration Checklist
data/README.md CHANGED
@@ -53,7 +53,7 @@ end
53
53
  - 🎨 Structured Output v1 reports (flag/list/hierarchical)
54
54
  - ✨ Meta-schema validation for schema documents, including custom metaschemas
55
55
  - 🧮 Experimental schema canonicalization
56
- - ♦️ Supports Ruby 3.2, 3.4 and 4.0
56
+ - ♦️ Supports Ruby 3.2+
57
57
 
58
58
  ### Supported drafts
59
59
 
@@ -117,9 +117,27 @@ validator = JSONSchema::Draft7Validator.new(schema)
117
117
  # Draft201909Validator, Draft202012Validator
118
118
  ```
119
119
 
120
+ With a chosen draft (a draft-specific class or `draft:`), the `$schema` URI is not retrieved: pass a custom meta-schema in `registry:` so its `$vocabulary` applies.
121
+
122
+ ### Validating JSON text
123
+
124
+ When instances arrive as JSON text, such as request bodies or queue messages,
125
+ `JsonTextValidator` validates the string directly, without building Ruby objects for it.
126
+ It takes the same keyword arguments as `validator_for`, plus `draft:`:
127
+
128
+ ```ruby
129
+ validator = JSONSchema::JsonTextValidator.new({ "type" => "object", "required" => ["id"] })
130
+
131
+ validator.valid?('{"id": 1}') # => true
132
+ validator.valid?('{"name": "x"}') # => false
133
+ ```
134
+
135
+ Text that is not a single JSON document raises `ArgumentError`, and a repeated key keeps its last
136
+ value, as with `JSON.parse`. Custom keywords receive the instance as Ruby objects.
137
+
120
138
  ### Custom format validators
121
139
 
122
- Pass a callable that takes a `String` and returns a boolean via `formats`. Drafts 2019-09 and 2020-12 treat `format` as an annotation, so set `validate_formats: true` to get it checked:
140
+ Pass a Proc or lambda that takes a `String` and returns a boolean via `formats`. Drafts 2019-09 and 2020-12 treat `format` as an annotation, so set `validate_formats: true` to get it checked:
123
141
 
124
142
  ```ruby
125
143
  phone_format = ->(value) { value.match?(/^\+?[1-9]\d{1,14}$/) }
@@ -131,6 +149,14 @@ validator = JSONSchema.validator_for(
131
149
  )
132
150
  ```
133
151
 
152
+ To check numbers, wrap the callable in `JSONSchema.number_format`; it receives an `Integer`, `Float` or `BigDecimal`:
153
+
154
+ ```ruby
155
+ int32 = JSONSchema.number_format(->(number) { number.between?(-(2**31), (2**31) - 1) })
156
+ validator = JSONSchema.validator_for({ "format" => "int32" }, validate_formats: true, formats: { "int32" => int32 })
157
+ validator.valid?(2**31) # => false
158
+ ```
159
+
134
160
  ### Custom keyword validators
135
161
 
136
162
  ```ruby
@@ -298,7 +324,7 @@ Use it to deduplicate schemas that differ only in key order.
298
324
 
299
325
  > **Experimental**: the canonicalization API may change in minor releases.
300
326
 
301
- `JSONSchema.canonicalize` reduces a schema to a normal form that accepts the same values. Schemas that accept the same values reduce to equal `CanonicalSchema` objects, and a schema proven to accept nothing reduces to `false`:
327
+ `JSONSchema.canonicalize` reduces a schema to a normal form that accepts the same values. Many schemas that accept the same values reduce to equal `CanonicalSchema` objects, and a schema proven to accept nothing reduces to `false`:
302
328
 
303
329
  ```ruby
304
330
  canonical = JSONSchema.canonicalize(
@@ -308,7 +334,7 @@ canonical.to_json_schema
308
334
  # => {"$schema"=>"https://json-schema.org/draft/2020-12/schema",
309
335
  # "type"=>"integer", "minimum"=>10, "maximum"=>100}
310
336
 
311
- # However they were written, equivalent schemas compare equal
337
+ # Written differently, these two schemas accept the same values and compare equal
312
338
  canonical == JSONSchema.canonicalize({ "type" => "integer", "maximum" => 100, "minimum" => 10 })
313
339
  # => true
314
340
 
@@ -317,34 +343,34 @@ JSONSchema.canonicalize({ "type" => "integer", "minimum" => 10, "maximum" => 5 }
317
343
  # => :no, which is JSONSchema::Canonical::Satisfiability::NO
318
344
  ```
319
345
 
320
- A schema the canonical form cannot model exactly comes back unchanged, with `kind == :raw`. Its `view.reason` names what stopped the run, and `view.pointer` the subschema at fault when a single one is.
346
+ A schema the canonical form cannot model exactly comes back unchanged, with `kind == :raw`. Its `view.reason` names why it stayed raw, and `view.pointer` the subschema at fault when a single one is.
321
347
 
322
348
  Canonical schemas combine like sets of values. Every emitted schema carries `$schema`; the comments below leave it out:
323
349
 
324
350
  ```ruby
325
- positive = JSONSchema.canonicalize({ "type" => "integer", "minimum" => 0 })
326
- bounded = JSONSchema.canonicalize({ "type" => "integer", "maximum" => 100 })
351
+ non_negative = JSONSchema.canonicalize({ "type" => "integer", "minimum" => 0 })
352
+ bounded = JSONSchema.canonicalize({ "type" => "integer", "maximum" => 100 })
327
353
 
328
- # Every value both admit
329
- positive.intersect(bounded).to_json_schema
354
+ # Every value both accept
355
+ non_negative.intersect(bounded).to_json_schema
330
356
  # => {"type"=>"integer", "minimum"=>0, "maximum"=>100}
331
357
 
332
- # Every value either admits
333
- positive.union(bounded).to_json_schema
358
+ # Every value either accepts
359
+ non_negative.union(bounded).to_json_schema
334
360
  # => {"type"=>"integer"}
335
361
 
336
- # Every value `positive` admits and `bounded` rejects
337
- positive.subtract(bounded).to_json_schema
362
+ # Every value `non_negative` accepts and `bounded` rejects
363
+ non_negative.subtract(bounded).to_json_schema
338
364
  # => {"type"=>"integer", "minimum"=>101}
339
365
 
340
- # Every value `positive` rejects: other types, negative integers and non-integer numbers
341
- positive.negate.to_json_schema
366
+ # Every value `non_negative` rejects: other types, negative integers and non-integer numbers
367
+ non_negative.negate.to_json_schema
342
368
  # => {"anyOf"=>[{"type"=>["null", "boolean", "string", "array", "object"]},
343
369
  # {"type"=>"integer", "maximum"=>-1},
344
370
  # {"type"=>"number", "not"=>{"multipleOf"=>1}}]}
345
371
 
346
- positive.covers(bounded) # => :no: `bounded` takes negative integers, `positive` does not
347
- positive.satisfiability # => :yes
372
+ non_negative.covers(bounded) # => :no: `bounded` accepts negative integers, `non_negative` rejects them
373
+ non_negative.satisfiability # => :yes
348
374
  ```
349
375
 
350
376
  ### Comparing two versions of a schema
@@ -375,7 +401,7 @@ The direction to check depends on who sends the value:
375
401
  - `satisfiability`: only `:no` proves a schema accepts nothing. Treat `:unknown` like `:yes`.
376
402
  - `a.covers(b)`: only `:yes` proves `a` accepts every value `b` accepts. Treat `:unknown` like `:no`.
377
403
 
378
- `JSONSchema::Canonical::Containment`, `Satisfiability`, `Distinctness` and `Kind` hold these symbols as constants, each with an `ALL` list.
404
+ `Containment`, `Satisfiability`, `Distinctness`, `Kind` and `RawReason` under `JSONSchema::Canonical` hold these symbols as constants, each with an `ALL` list.
379
405
 
380
406
  The set operations raise `IncompatibleOperands` when the operands differ in draft, `format` assertion or regular-expression engine, or resolve `#` or one external resource to different schemas. They raise `UnsupportedOperand` when an operand is `:raw`, and `UnsupportedResult` when the canonical form cannot express the result exactly. All three live under `JSONSchema::Canonical`.
381
407
 
@@ -404,7 +430,7 @@ reasons.key?("/properties/name")
404
430
  # => false
405
431
  ```
406
432
 
407
- A reason is a `LiteralReason` (written as `false`), an `EmptyReason` (one part admits nothing by itself) or a `ConflictReason` (each part admits values, together they admit none). A missing pointer does not prove that subschema satisfiable. For a document the canonical form cannot model, `find_unsatisfiable` reports nothing, the same way `satisfiability` answers `:unknown`.
433
+ A reason is a `LiteralReason` (written as `false`), an `EmptyReason` (one part accepts nothing by itself) or a `ConflictReason` (each part accepts values, together they accept none). A missing pointer does not prove that subschema satisfiable. For a document the canonical form cannot model, `find_unsatisfiable` reports nothing, the same way `satisfiability` answers `:unknown`.
408
434
 
409
435
  ## Schema Bundling and Dereferencing
410
436
 
@@ -573,6 +599,14 @@ validator = JSONSchema.validator_for(
573
599
  dfa_size_limit: 10240 # Maximum DFA cache size
574
600
  )
575
601
  )
602
+
603
+ # Patterns in the engine's own syntax instead of ECMA 262:
604
+ # `\d` matches every Unicode decimal digit, as in the Rust `regex` crate
605
+ validator = JSONSchema.validator_for(
606
+ { "type" => "string", "pattern" => "^\\d+$" },
607
+ pattern_options: JSONSchema::RegexOptions.new(syntax: :engine)
608
+ )
609
+ validator.valid?("٣") # => true
576
610
  ```
577
611
 
578
612
  - `FancyRegexOptions`: default engine, supports lookaround and backreferences
@@ -586,6 +620,8 @@ validator = JSONSchema.validator_for(
586
620
  - `size_limit`: Maximum compiled regex size in bytes
587
621
  - `dfa_size_limit`: Maximum DFA cache size in bytes
588
622
 
623
+ Both take `syntax:`: `:ecma262` (default) translates patterns for the engine, `:engine` passes them to it unchanged. Use `:engine` for schemas whose patterns are written for the Rust [`regex`](https://docs.rs/regex/latest/regex/#syntax) or [`fancy-regex`](https://docs.rs/fancy-regex/latest/fancy_regex/#syntax) crate.
624
+
589
625
  If you validate against schemas from untrusted sources, use `RegexOptions`: a crafted pattern cannot make it backtrack.
590
626
 
591
627
  ## Email Format Configuration
@@ -627,7 +663,7 @@ validator = JSONSchema.validator_for(
627
663
 
628
664
  ## Error Handling
629
665
 
630
- A `ValidationError` carries the message, both locations and a `kind` with keyword-specific details:
666
+ A `ValidationError` carries the message, the instance and schema paths, and a `kind` with keyword-specific details:
631
667
 
632
668
  ```ruby
633
669
  schema = { "type" => "string", "maxLength" => 5 }
@@ -643,8 +679,8 @@ rescue JSONSchema::ValidationError => error
643
679
 
644
680
  # Detailed error information via `kind`
645
681
  error.kind.name # => "maxLength"
646
- error.kind.value # => { "limit" => 5 }
647
- error.kind.to_h # => { "name" => "maxLength", "value" => { "limit" => 5 } }
682
+ error.kind.value # => { limit: 5 }
683
+ error.kind.to_h # => { name: "maxLength", value: { limit: 5 } }
648
684
  end
649
685
  ```
650
686
 
@@ -655,8 +691,8 @@ end
655
691
  ```ruby
656
692
  JSONSchema.each_error({ "minimum" => 5 }, 3).each do |error|
657
693
  error.kind.name # => "minimum"
658
- error.kind.value # => { "limit" => 5 }
659
- error.kind.to_h # => { "name" => "minimum", "value" => { "limit" => 5 } }
694
+ error.kind.value # => { limit: 5 }
695
+ error.kind.to_h # => { name: "minimum", value: { limit: 5 } }
660
696
  error.kind.to_s # => "minimum"
661
697
  end
662
698
  ```
@@ -680,16 +716,16 @@ begin
680
716
  validator.validate!({ "password" => "123", "api_key" => "secret_key_123" })
681
717
  rescue JSONSchema::ValidationError => exc
682
718
  puts exc.message
683
- # => '[REDACTED] does not match "^[A-Z0-9]{32}$"'
719
+ # => '[REDACTED] is shorter than 8 characters'
684
720
  puts exc.verbose_message
685
- # => '[REDACTED] does not match "^[A-Z0-9]{32}$"\n\nFailed validating...\nOn instance["api_key"]:\n [REDACTED]'
721
+ # => '[REDACTED] is shorter than 8 characters\n\nFailed validating...\nOn instance["password"]:\n [REDACTED]'
686
722
  end
687
723
  ```
688
724
 
689
725
  ### Exception Classes
690
726
 
691
727
  - **`JSONSchema::ValidationError`**: raised on validation failure
692
- - `message`, `verbose_message`, `instance_path`, `schema_path`, `evaluation_path`, `kind`, `instance`
728
+ - `message`, `verbose_message`, `instance_path`, `schema_path`, `evaluation_path`, `kind`, `instance`, `absolute_keyword_location`
693
729
  - JSON Pointer helpers: `instance_path_pointer`, `schema_path_pointer`, `evaluation_path_pointer`
694
730
  - **`JSONSchema::ReferencingError`**: raised when a `$ref` cannot be resolved
695
731
 
@@ -716,7 +752,7 @@ JSONSchema.valid?(schema, instance,
716
752
  )
717
753
  ```
718
754
 
719
- `evaluate` accepts the same options except `mask` (currently unsupported for evaluation output).
755
+ `evaluate` accepts the same options except `mask`.
720
756
 
721
757
  `validator_for` accepts the same options except `draft:`. To pin a draft, use a draft-specific class such as `Draft7Validator.new`.
722
758
 
@@ -726,9 +762,9 @@ Valid draft symbols: `:draft4`, `:draft6`, `:draft7`, `:draft201909`, `:draft202
726
762
 
727
763
  Compared with other Ruby validators:
728
764
 
729
- - **96-1,189x** faster than `json_schemer` for complex schemas and large instances
730
- - **987-1,081x** faster than `json-schema` where supported
731
- - **25-161x** faster than `rj_schema` (RapidJSON/C++)
765
+ - **96-2,891,549x** faster than `json_schemer`
766
+ - **987-342,162x** faster than `json-schema` where supported
767
+ - **25-1,638,462x** faster than `rj_schema` (RapidJSON/C++) where supported
732
768
 
733
769
  Full results and methodology are in [BENCHMARKS.md](https://github.com/Stranger6667/jsonschema/blob/master/crates/jsonschema-rb/BENCHMARKS.md).
734
770
 
@@ -693,9 +693,9 @@ dependencies = [
693
693
 
694
694
  [[package]]
695
695
  name = "jsonschema"
696
- version = "0.61.2"
696
+ version = "0.63.0"
697
697
  source = "registry+https://github.com/rust-lang/crates.io-index"
698
- checksum = "0e37f27df77c7887edbc5f5a59ecd8e5ec4a669319266ec1b61068667a603183"
698
+ checksum = "f4d2afab27172a0073112ce84a64ec7fd06f3b8bdad37d46e86c53c933ed232b"
699
699
  dependencies = [
700
700
  "ahash",
701
701
  "bytecount",
@@ -727,9 +727,9 @@ dependencies = [
727
727
 
728
728
  [[package]]
729
729
  name = "jsonschema-macros"
730
- version = "0.61.2"
730
+ version = "0.63.0"
731
731
  source = "registry+https://github.com/rust-lang/crates.io-index"
732
- checksum = "e3467cc02f0e5de53d77834726a4744c61bdd239336ae49902ff0cbf1842d930"
732
+ checksum = "d3dc0b4debd8aecd40d1f0d432d5ecf259c24b6feaccb8ebc8c610338c5d0f89"
733
733
  dependencies = [
734
734
  "jsonschema-macros-core",
735
735
  "proc-macro2",
@@ -737,9 +737,9 @@ dependencies = [
737
737
 
738
738
  [[package]]
739
739
  name = "jsonschema-macros-core"
740
- version = "0.61.2"
740
+ version = "0.63.0"
741
741
  source = "registry+https://github.com/rust-lang/crates.io-index"
742
- checksum = "75afa4b5e6986cc221f5339d7d6149360f0bf8e65bcb23617dc0f92900b576d2"
742
+ checksum = "197a3766e68338d53685acd4120d7bdc3e1419f0a044a1e4110f8f6ecc1bc1b6"
743
743
  dependencies = [
744
744
  "fancy-regex",
745
745
  "indexmap",
@@ -751,12 +751,12 @@ dependencies = [
751
751
  "referencing",
752
752
  "regex",
753
753
  "serde_json",
754
- "syn 2.0.117",
754
+ "syn 3.0.6",
755
755
  ]
756
756
 
757
757
  [[package]]
758
758
  name = "jsonschema-rb-ext"
759
- version = "0.61.2"
759
+ version = "0.63.0"
760
760
  dependencies = [
761
761
  "jsonschema",
762
762
  "magnus",
@@ -770,18 +770,18 @@ dependencies = [
770
770
 
771
771
  [[package]]
772
772
  name = "jsonschema-regex"
773
- version = "0.61.2"
773
+ version = "0.63.0"
774
774
  source = "registry+https://github.com/rust-lang/crates.io-index"
775
- checksum = "7e41151614b6c927e21982be8bef5a26741ae5a0ae6a781eedee2aa930a980e6"
775
+ checksum = "19532291f4c1f5a5726be72105a0d73620b714ef12256e9748cc863cf122dc1c"
776
776
  dependencies = [
777
777
  "regex-syntax",
778
778
  ]
779
779
 
780
780
  [[package]]
781
781
  name = "jsonschema-value"
782
- version = "0.61.2"
782
+ version = "0.63.0"
783
783
  source = "registry+https://github.com/rust-lang/crates.io-index"
784
- checksum = "1515b9a91134ef67d7bac95c2d76fbc7e383c4c55ee544204ceec8088f881fef"
784
+ checksum = "d455c96d26f5c8527d7824f3f9ac810fec24d1448a3f7a254a006ea542e3dcf9"
785
785
  dependencies = [
786
786
  "ahash",
787
787
  "bytecount",
@@ -1137,9 +1137,9 @@ dependencies = [
1137
1137
 
1138
1138
  [[package]]
1139
1139
  name = "referencing"
1140
- version = "0.61.2"
1140
+ version = "0.63.0"
1141
1141
  source = "registry+https://github.com/rust-lang/crates.io-index"
1142
- checksum = "a028057ef852c58a42d75e09da87b5e733f4030f4c7411728955e4f87203a577"
1142
+ checksum = "1225f3e462cea1e4a8e169dd539f9d8a7592780b5b261d0e07e5cbb9efb28e4e"
1143
1143
  dependencies = [
1144
1144
  "ahash",
1145
1145
  "fluent-uri",
@@ -1154,9 +1154,9 @@ dependencies = [
1154
1154
 
1155
1155
  [[package]]
1156
1156
  name = "regex"
1157
- version = "1.12.3"
1157
+ version = "1.13.2"
1158
1158
  source = "registry+https://github.com/rust-lang/crates.io-index"
1159
- checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
1159
+ checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857"
1160
1160
  dependencies = [
1161
1161
  "aho-corasick",
1162
1162
  "memchr",
@@ -1166,9 +1166,9 @@ dependencies = [
1166
1166
 
1167
1167
  [[package]]
1168
1168
  name = "regex-automata"
1169
- version = "0.4.18"
1169
+ version = "0.4.19"
1170
1170
  source = "registry+https://github.com/rust-lang/crates.io-index"
1171
- checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
1171
+ checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
1172
1172
  dependencies = [
1173
1173
  "aho-corasick",
1174
1174
  "memchr",
@@ -1177,9 +1177,9 @@ dependencies = [
1177
1177
 
1178
1178
  [[package]]
1179
1179
  name = "regex-syntax"
1180
- version = "0.8.10"
1180
+ version = "0.8.12"
1181
1181
  source = "registry+https://github.com/rust-lang/crates.io-index"
1182
- checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
1182
+ checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
1183
1183
 
1184
1184
  [[package]]
1185
1185
  name = "reqwest"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb-ext"
3
- version = "0.61.2"
3
+ version = "0.63.0"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
@@ -10,10 +10,10 @@ name = "jsonschema_rb"
10
10
  path = "../../src/lib.rs"
11
11
 
12
12
  [dependencies]
13
- jsonschema = { version = "0.61.2", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna"] }
13
+ jsonschema = { version = "0.63.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna", "json-text"] }
14
14
  magnus = { version = "0.9", features = ["rb-sys"] }
15
15
  rb-sys = "0.9"
16
- referencing = "0.61.2"
16
+ referencing = "0.63.0"
17
17
  serde = { version = "1", features = ["derive"] }
18
18
  serde_json = { version = "1", features = ["arbitrary_precision"] }
19
19
  strum = "0.28.0"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.61.2"
4
+ VERSION = "0.63.0"
5
5
  end