jsonschema_rs 0.61.2-x86_64-linux → 0.62.0-x86_64-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 +90 -1
- data/MIGRATION.md +10 -12
- data/README.md +43 -31
- 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
- data/sig/jsonschema.rbs +90 -63
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e86780129b9c55d4bc1dbef93849d00a3b2f74f778e788cf449cdba44c5e686e
|
|
4
|
+
data.tar.gz: 64e3123a73e29a570ece8da1d4da7a959b365a031dac34515c474695b6f9d05f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a6f38576f907dc0877a16c2d680f7db511b6c4b8fb91470359911d90f219eaa431cda0ac689eb1b586059ecdc84c102aa85939fdf6d39d22c0d87628c11d101
|
|
7
|
+
data.tar.gz: 59f77d624b5869731a80c565dc0e375e5f9b6eda9d6af2a12e9ea98c477dec73b8686459faa18d55f2825a082d60167540c2be0cd2173b1fe96283d0b2c09965
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,94 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.62.0] - 2026-11-21
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `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)
|
|
10
|
+
- `Resolver#lookup_dynamic_ref` to resolve a `$dynamicRef` through the dynamic scope. [#1923](https://github.com/Stranger6667/jsonschema/issues/1923)
|
|
11
|
+
- `minContains` and `maxContains` error kinds.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Non-string keys of a root `Hash` raising only when validation reads them, like keys of nested ones, instead of on every call.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
#### References and `$schema`
|
|
20
|
+
|
|
21
|
+
- `$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)
|
|
22
|
+
- `$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.
|
|
23
|
+
- `$recursiveRef` stopping at a resource without `$recursiveAnchor: true` in the dynamic scope instead of resolving to the outermost resource with `$recursiveAnchor: true`.
|
|
24
|
+
- `$dynamicRef` landing in another resource leaving the resource that holds it out of the dynamic scope.
|
|
25
|
+
- `Validator` results depending on how references name a schema that a `$ref` cycle passes through, such as `cycle` and `#` inside it.
|
|
26
|
+
- `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.
|
|
27
|
+
- 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.
|
|
28
|
+
- `validator_map_for` entries accepting every value for a subschema in Draft 2019-09 or later under a Draft 7 or earlier root.
|
|
29
|
+
- `validator_map_for` entries below the root differing from the same subschema reached through a `$ref`.
|
|
30
|
+
- `$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`.
|
|
31
|
+
|
|
32
|
+
#### `evaluate` output
|
|
33
|
+
|
|
34
|
+
- 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.
|
|
35
|
+
- 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"`.
|
|
36
|
+
- `properties` or `patternProperties` beside `additionalProperties` reporting their subschemas inside the `additionalProperties` unit instead of in units of their own.
|
|
37
|
+
- One `required` name beside `properties` and `additionalProperties: false` reporting the name inside the `additionalProperties` unit, and only when missing.
|
|
38
|
+
- `additionalProperties: false` reporting one error for the whole object instead of a failing unit for each extra member.
|
|
39
|
+
- Two `required` names beside `properties` reporting them inside the `properties` unit, failing it, and only when missing.
|
|
40
|
+
- `propertyNames: false` reporting one error for the whole object instead of a failing unit for each name.
|
|
41
|
+
- `dependentRequired` and the array form of `dependencies` reporting missing names in a nested unit at a schema location that does not exist.
|
|
42
|
+
- Array-form `items` and `additionalItems` missing their annotations, and `additionalItems` reporting the extra items in one error instead of a unit for each.
|
|
43
|
+
- `contains` beside `minContains` or `maxContains` missing the matching items and their indices, and locating the subschema at the bound keyword instead of at `contains`.
|
|
44
|
+
- `then` and `else` reported inside the `if` unit instead of in units of their own.
|
|
45
|
+
- `oneOf` with more than one valid subschema reporting a different message than `validate`.
|
|
46
|
+
- `contains` annotating an instance that is not an array.
|
|
47
|
+
- Locating a `$ref` target at the URI its document was registered under instead of the `$id` that document declares.
|
|
48
|
+
|
|
49
|
+
#### Error locations and messages
|
|
50
|
+
|
|
51
|
+
- Evaluation paths of custom keyword errors leaving out the `$ref` the keyword was reached through.
|
|
52
|
+
- Evaluation paths below a subschema reached both inline and through a `$ref` taking part of their path from the other route.
|
|
53
|
+
- Error messages for `minContains` and `maxContains` claiming that no item is valid under the `contains` subschema.
|
|
54
|
+
- Evaluation paths of `propertyNames` errors leaving out a `$ref` inside `propertyNames`.
|
|
55
|
+
- `absolute_keyword_location` of errors for names missing under `dependentRequired` or `dependencies` pointing to a schema location that does not exist.
|
|
56
|
+
- `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.
|
|
57
|
+
- `propertyNames` errors reporting `propertyNames` as their absolute keyword location instead of the keyword that rejected the name.
|
|
58
|
+
|
|
59
|
+
#### Keywords
|
|
60
|
+
|
|
61
|
+
- `unevaluatedItems` in Draft 2019-09 treating items matched by `contains` as evaluated.
|
|
62
|
+
- `contentEncoding` going unchecked in Draft 7 beside an unsupported `contentMediaType`.
|
|
63
|
+
- `contentEncoding` and `contentMediaType` asserted in Draft 6, which does not define them.
|
|
64
|
+
- `unevaluatedProperties` and `unevaluatedItems` errors and `evaluate` output counting members as evaluated by a subschema that fails, such as a `$ref` target.
|
|
65
|
+
- `multipleOf` with an integer divisor above 2^53 accepting numbers too small for `Float`, such as `BigDecimal("1e-400")`.
|
|
66
|
+
- `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.
|
|
67
|
+
|
|
68
|
+
#### `dereference`
|
|
69
|
+
|
|
70
|
+
- `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.
|
|
71
|
+
- `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`.
|
|
72
|
+
- `dereference` keeping siblings of `$ref` that Draft 4, 6 and 7 ignore, such as `minimum` or `$id`.
|
|
73
|
+
|
|
74
|
+
### Performance
|
|
75
|
+
|
|
76
|
+
#### Building validators
|
|
77
|
+
|
|
78
|
+
- Fewer allocations per subschema when building a validator.
|
|
79
|
+
- Faster validator builds for valid schemas, which skip collecting meta-schema errors.
|
|
80
|
+
|
|
81
|
+
#### Validation
|
|
82
|
+
|
|
83
|
+
- Lower cost of collecting errors over the valid parts of an instance.
|
|
84
|
+
- Fewer allocations in `evaluate` for arrays, with every `items` and `additionalItems` annotation sharing one value.
|
|
85
|
+
- 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.
|
|
86
|
+
- `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.
|
|
87
|
+
- `Hash` member snapshots built in place and filled without a GC write barrier per member.
|
|
88
|
+
- `pattern` and `patternProperties` with alternations of anchored sequences, such as `^[1-5](?:[0-9]{2}|XX)$`, matched in one pass without a regex engine.
|
|
89
|
+
- `unevaluatedProperties` matching names against sequence-shaped `patternProperties`, such as `^[a-z0-9-]+$` or `^[1-5](?:[0-9]{2}|XX)$`, without a regex engine.
|
|
90
|
+
- `properties` and a sibling `unevaluatedProperties` checked in one pass over the object by `is_valid`.
|
|
91
|
+
- `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.
|
|
92
|
+
|
|
5
93
|
## [0.61.2] - 2026-11-12
|
|
6
94
|
|
|
7
95
|
### Fixed
|
|
@@ -766,7 +854,8 @@
|
|
|
766
854
|
|
|
767
855
|
- Initial public release
|
|
768
856
|
|
|
769
|
-
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.
|
|
857
|
+
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.62.0...HEAD
|
|
858
|
+
[0.62.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.2...ruby-v0.62.0
|
|
770
859
|
[0.61.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.1...ruby-v0.61.2
|
|
771
860
|
[0.61.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.0...ruby-v0.61.1
|
|
772
861
|
[0.61.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.60.2...ruby-v0.61.0
|
data/MIGRATION.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Quick Reference
|
|
4
4
|
|
|
5
|
-
| json_schemer |
|
|
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
|
|
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,
|
|
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
|
-
#
|
|
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 # => "
|
|
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 # => {
|
|
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
|
-
#
|
|
57
|
+
# jsonschema_rs — retriever
|
|
60
58
|
JSONSchema.validator_for(schema, retriever: ->(uri) { fetch_schema(uri) })
|
|
61
59
|
|
|
62
|
-
#
|
|
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** —
|
|
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` —
|
|
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
|
|
56
|
+
- ♦️ Supports Ruby 3.2+
|
|
57
57
|
|
|
58
58
|
### Supported drafts
|
|
59
59
|
|
|
@@ -117,9 +117,11 @@ 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
|
+
|
|
120
122
|
### Custom format validators
|
|
121
123
|
|
|
122
|
-
Pass a
|
|
124
|
+
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
125
|
|
|
124
126
|
```ruby
|
|
125
127
|
phone_format = ->(value) { value.match?(/^\+?[1-9]\d{1,14}$/) }
|
|
@@ -298,7 +300,7 @@ Use it to deduplicate schemas that differ only in key order.
|
|
|
298
300
|
|
|
299
301
|
> **Experimental**: the canonicalization API may change in minor releases.
|
|
300
302
|
|
|
301
|
-
`JSONSchema.canonicalize` reduces a schema to a normal form that accepts the same values.
|
|
303
|
+
`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
304
|
|
|
303
305
|
```ruby
|
|
304
306
|
canonical = JSONSchema.canonicalize(
|
|
@@ -308,7 +310,7 @@ canonical.to_json_schema
|
|
|
308
310
|
# => {"$schema"=>"https://json-schema.org/draft/2020-12/schema",
|
|
309
311
|
# "type"=>"integer", "minimum"=>10, "maximum"=>100}
|
|
310
312
|
|
|
311
|
-
#
|
|
313
|
+
# Written differently, these two schemas accept the same values and compare equal
|
|
312
314
|
canonical == JSONSchema.canonicalize({ "type" => "integer", "maximum" => 100, "minimum" => 10 })
|
|
313
315
|
# => true
|
|
314
316
|
|
|
@@ -317,34 +319,34 @@ JSONSchema.canonicalize({ "type" => "integer", "minimum" => 10, "maximum" => 5 }
|
|
|
317
319
|
# => :no, which is JSONSchema::Canonical::Satisfiability::NO
|
|
318
320
|
```
|
|
319
321
|
|
|
320
|
-
A schema the canonical form cannot model exactly comes back unchanged, with `kind == :raw`. Its `view.reason` names
|
|
322
|
+
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
323
|
|
|
322
324
|
Canonical schemas combine like sets of values. Every emitted schema carries `$schema`; the comments below leave it out:
|
|
323
325
|
|
|
324
326
|
```ruby
|
|
325
|
-
|
|
326
|
-
bounded
|
|
327
|
+
non_negative = JSONSchema.canonicalize({ "type" => "integer", "minimum" => 0 })
|
|
328
|
+
bounded = JSONSchema.canonicalize({ "type" => "integer", "maximum" => 100 })
|
|
327
329
|
|
|
328
|
-
# Every value both
|
|
329
|
-
|
|
330
|
+
# Every value both accept
|
|
331
|
+
non_negative.intersect(bounded).to_json_schema
|
|
330
332
|
# => {"type"=>"integer", "minimum"=>0, "maximum"=>100}
|
|
331
333
|
|
|
332
|
-
# Every value either
|
|
333
|
-
|
|
334
|
+
# Every value either accepts
|
|
335
|
+
non_negative.union(bounded).to_json_schema
|
|
334
336
|
# => {"type"=>"integer"}
|
|
335
337
|
|
|
336
|
-
# Every value `
|
|
337
|
-
|
|
338
|
+
# Every value `non_negative` accepts and `bounded` rejects
|
|
339
|
+
non_negative.subtract(bounded).to_json_schema
|
|
338
340
|
# => {"type"=>"integer", "minimum"=>101}
|
|
339
341
|
|
|
340
|
-
# Every value `
|
|
341
|
-
|
|
342
|
+
# Every value `non_negative` rejects: other types, negative integers and non-integer numbers
|
|
343
|
+
non_negative.negate.to_json_schema
|
|
342
344
|
# => {"anyOf"=>[{"type"=>["null", "boolean", "string", "array", "object"]},
|
|
343
345
|
# {"type"=>"integer", "maximum"=>-1},
|
|
344
346
|
# {"type"=>"number", "not"=>{"multipleOf"=>1}}]}
|
|
345
347
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
+
non_negative.covers(bounded) # => :no: `bounded` accepts negative integers, `non_negative` rejects them
|
|
349
|
+
non_negative.satisfiability # => :yes
|
|
348
350
|
```
|
|
349
351
|
|
|
350
352
|
### Comparing two versions of a schema
|
|
@@ -375,7 +377,7 @@ The direction to check depends on who sends the value:
|
|
|
375
377
|
- `satisfiability`: only `:no` proves a schema accepts nothing. Treat `:unknown` like `:yes`.
|
|
376
378
|
- `a.covers(b)`: only `:yes` proves `a` accepts every value `b` accepts. Treat `:unknown` like `:no`.
|
|
377
379
|
|
|
378
|
-
`
|
|
380
|
+
`Containment`, `Satisfiability`, `Distinctness`, `Kind` and `RawReason` under `JSONSchema::Canonical` hold these symbols as constants, each with an `ALL` list.
|
|
379
381
|
|
|
380
382
|
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
383
|
|
|
@@ -404,7 +406,7 @@ reasons.key?("/properties/name")
|
|
|
404
406
|
# => false
|
|
405
407
|
```
|
|
406
408
|
|
|
407
|
-
A reason is a `LiteralReason` (written as `false`), an `EmptyReason` (one part
|
|
409
|
+
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
410
|
|
|
409
411
|
## Schema Bundling and Dereferencing
|
|
410
412
|
|
|
@@ -573,6 +575,14 @@ validator = JSONSchema.validator_for(
|
|
|
573
575
|
dfa_size_limit: 10240 # Maximum DFA cache size
|
|
574
576
|
)
|
|
575
577
|
)
|
|
578
|
+
|
|
579
|
+
# Patterns in the engine's own syntax instead of ECMA 262:
|
|
580
|
+
# `\d` matches every Unicode decimal digit, as in the Rust `regex` crate
|
|
581
|
+
validator = JSONSchema.validator_for(
|
|
582
|
+
{ "type" => "string", "pattern" => "^\\d+$" },
|
|
583
|
+
pattern_options: JSONSchema::RegexOptions.new(syntax: :engine)
|
|
584
|
+
)
|
|
585
|
+
validator.valid?("٣") # => true
|
|
576
586
|
```
|
|
577
587
|
|
|
578
588
|
- `FancyRegexOptions`: default engine, supports lookaround and backreferences
|
|
@@ -586,6 +596,8 @@ validator = JSONSchema.validator_for(
|
|
|
586
596
|
- `size_limit`: Maximum compiled regex size in bytes
|
|
587
597
|
- `dfa_size_limit`: Maximum DFA cache size in bytes
|
|
588
598
|
|
|
599
|
+
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.
|
|
600
|
+
|
|
589
601
|
If you validate against schemas from untrusted sources, use `RegexOptions`: a crafted pattern cannot make it backtrack.
|
|
590
602
|
|
|
591
603
|
## Email Format Configuration
|
|
@@ -627,7 +639,7 @@ validator = JSONSchema.validator_for(
|
|
|
627
639
|
|
|
628
640
|
## Error Handling
|
|
629
641
|
|
|
630
|
-
A `ValidationError` carries the message,
|
|
642
|
+
A `ValidationError` carries the message, the instance and schema paths, and a `kind` with keyword-specific details:
|
|
631
643
|
|
|
632
644
|
```ruby
|
|
633
645
|
schema = { "type" => "string", "maxLength" => 5 }
|
|
@@ -643,8 +655,8 @@ rescue JSONSchema::ValidationError => error
|
|
|
643
655
|
|
|
644
656
|
# Detailed error information via `kind`
|
|
645
657
|
error.kind.name # => "maxLength"
|
|
646
|
-
error.kind.value # => {
|
|
647
|
-
error.kind.to_h # => {
|
|
658
|
+
error.kind.value # => { limit: 5 }
|
|
659
|
+
error.kind.to_h # => { name: "maxLength", value: { limit: 5 } }
|
|
648
660
|
end
|
|
649
661
|
```
|
|
650
662
|
|
|
@@ -655,8 +667,8 @@ end
|
|
|
655
667
|
```ruby
|
|
656
668
|
JSONSchema.each_error({ "minimum" => 5 }, 3).each do |error|
|
|
657
669
|
error.kind.name # => "minimum"
|
|
658
|
-
error.kind.value # => {
|
|
659
|
-
error.kind.to_h # => {
|
|
670
|
+
error.kind.value # => { limit: 5 }
|
|
671
|
+
error.kind.to_h # => { name: "minimum", value: { limit: 5 } }
|
|
660
672
|
error.kind.to_s # => "minimum"
|
|
661
673
|
end
|
|
662
674
|
```
|
|
@@ -680,16 +692,16 @@ begin
|
|
|
680
692
|
validator.validate!({ "password" => "123", "api_key" => "secret_key_123" })
|
|
681
693
|
rescue JSONSchema::ValidationError => exc
|
|
682
694
|
puts exc.message
|
|
683
|
-
# => '[REDACTED]
|
|
695
|
+
# => '[REDACTED] is shorter than 8 characters'
|
|
684
696
|
puts exc.verbose_message
|
|
685
|
-
# => '[REDACTED]
|
|
697
|
+
# => '[REDACTED] is shorter than 8 characters\n\nFailed validating...\nOn instance["password"]:\n [REDACTED]'
|
|
686
698
|
end
|
|
687
699
|
```
|
|
688
700
|
|
|
689
701
|
### Exception Classes
|
|
690
702
|
|
|
691
703
|
- **`JSONSchema::ValidationError`**: raised on validation failure
|
|
692
|
-
- `message`, `verbose_message`, `instance_path`, `schema_path`, `evaluation_path`, `kind`, `instance`
|
|
704
|
+
- `message`, `verbose_message`, `instance_path`, `schema_path`, `evaluation_path`, `kind`, `instance`, `absolute_keyword_location`
|
|
693
705
|
- JSON Pointer helpers: `instance_path_pointer`, `schema_path_pointer`, `evaluation_path_pointer`
|
|
694
706
|
- **`JSONSchema::ReferencingError`**: raised when a `$ref` cannot be resolved
|
|
695
707
|
|
|
@@ -716,7 +728,7 @@ JSONSchema.valid?(schema, instance,
|
|
|
716
728
|
)
|
|
717
729
|
```
|
|
718
730
|
|
|
719
|
-
`evaluate` accepts the same options except `mask
|
|
731
|
+
`evaluate` accepts the same options except `mask`.
|
|
720
732
|
|
|
721
733
|
`validator_for` accepts the same options except `draft:`. To pin a draft, use a draft-specific class such as `Draft7Validator.new`.
|
|
722
734
|
|
|
@@ -726,9 +738,9 @@ Valid draft symbols: `:draft4`, `:draft6`, `:draft7`, `:draft201909`, `:draft202
|
|
|
726
738
|
|
|
727
739
|
Compared with other Ruby validators:
|
|
728
740
|
|
|
729
|
-
- **96-
|
|
730
|
-
- **987-
|
|
731
|
-
- **25-
|
|
741
|
+
- **96-2,891,549x** faster than `json_schemer`
|
|
742
|
+
- **987-342,162x** faster than `json-schema` where supported
|
|
743
|
+
- **25-1,638,462x** faster than `rj_schema` (RapidJSON/C++) where supported
|
|
732
744
|
|
|
733
745
|
Full results and methodology are in [BENCHMARKS.md](https://github.com/Stranger6667/jsonschema/blob/master/crates/jsonschema-rb/BENCHMARKS.md).
|
|
734
746
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/jsonschema/version.rb
CHANGED
data/sig/jsonschema.rbs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
# Type
|
|
2
|
-
# High-performance JSON Schema validation for Ruby
|
|
1
|
+
# Type signatures for the jsonschema_rs gem
|
|
3
2
|
|
|
4
3
|
module JSONSchema
|
|
5
4
|
VERSION: String
|
|
6
5
|
|
|
6
|
+
# Draft identifiers that `Resolved#draft` returns.
|
|
7
|
+
Draft4: Integer
|
|
8
|
+
Draft6: Integer
|
|
9
|
+
Draft7: Integer
|
|
10
|
+
Draft201909: Integer
|
|
11
|
+
Draft202012: Integer
|
|
12
|
+
|
|
7
13
|
# Valid draft version symbols
|
|
8
14
|
type draft = :draft4 | :draft6 | :draft7 | :draft201909 | :draft202012
|
|
9
15
|
|
|
@@ -23,15 +29,15 @@ module JSONSchema
|
|
|
23
29
|
# What an array requires of its elements: all distinct, some repeated, or neither.
|
|
24
30
|
type distinctness = :unconstrained | :all_distinct | :some_repeated
|
|
25
31
|
|
|
26
|
-
#
|
|
32
|
+
# Why canonicalization kept a schema verbatim.
|
|
27
33
|
type raw_reason = :unknown_dialect | :unmodeled | :outgrew_intersections
|
|
28
34
|
| :outgrew_cases | :inexact_intersection
|
|
29
35
|
|
|
30
|
-
# Whether one schema
|
|
36
|
+
# Whether one schema accepts every value another does. Only `:yes` proves containment: test
|
|
31
37
|
# for `:yes`, and treat `:unknown` like `:no`.
|
|
32
38
|
type containment = :yes | :no | :unknown
|
|
33
39
|
|
|
34
|
-
# Whether any value satisfies a schema. Only `:no` proves it
|
|
40
|
+
# Whether any value satisfies a schema. Only `:no` proves it accepts nothing: test for `:no`,
|
|
35
41
|
# and treat `:unknown` like `:yes`.
|
|
36
42
|
type satisfiability = :yes | :no | :unknown
|
|
37
43
|
|
|
@@ -109,7 +115,7 @@ module JSONSchema
|
|
|
109
115
|
class UnsupportedResult < CanonicalizationError
|
|
110
116
|
end
|
|
111
117
|
|
|
112
|
-
# A schema reduced to canonical form
|
|
118
|
+
# A schema reduced to canonical form; many schemas accepting the same values share one.
|
|
113
119
|
class CanonicalSchema
|
|
114
120
|
def to_json_schema: () -> untyped
|
|
115
121
|
def draft: () -> JSONSchema::draft
|
|
@@ -129,22 +135,22 @@ module JSONSchema
|
|
|
129
135
|
def hash: () -> Integer
|
|
130
136
|
end
|
|
131
137
|
|
|
132
|
-
#
|
|
138
|
+
# Accepts every value.
|
|
133
139
|
class TrueView
|
|
134
140
|
end
|
|
135
141
|
|
|
136
|
-
#
|
|
142
|
+
# Rejects every value.
|
|
137
143
|
class FalseView
|
|
138
144
|
end
|
|
139
145
|
|
|
140
|
-
#
|
|
146
|
+
# Accepts a value whose JSON type is in `types`.
|
|
141
147
|
class MultiTypeView
|
|
142
148
|
def types: () -> Array[Symbol]
|
|
143
149
|
def inspect: () -> String
|
|
144
150
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
145
151
|
end
|
|
146
152
|
|
|
147
|
-
#
|
|
153
|
+
# Accepts a value of JSON type `type_name` that `body` accepts.
|
|
148
154
|
class TypedGroupView
|
|
149
155
|
def type_name: () -> Symbol
|
|
150
156
|
def body: () -> CanonicalSchema
|
|
@@ -152,7 +158,7 @@ module JSONSchema
|
|
|
152
158
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
153
159
|
end
|
|
154
160
|
|
|
155
|
-
# A string
|
|
161
|
+
# A string within `min_length`..`max_length`, matching every listed constraint and none of the excluded ones.
|
|
156
162
|
class StringView
|
|
157
163
|
def min_length: () -> Integer?
|
|
158
164
|
def max_length: () -> Integer?
|
|
@@ -169,28 +175,28 @@ module JSONSchema
|
|
|
169
175
|
|
|
170
176
|
# A number value within a real interval.
|
|
171
177
|
class NumberView
|
|
172
|
-
def minimum: () ->
|
|
178
|
+
def minimum: () -> Numeric?
|
|
173
179
|
def exclusive_minimum: () -> bool
|
|
174
|
-
def maximum: () ->
|
|
180
|
+
def maximum: () -> Numeric?
|
|
175
181
|
def exclusive_maximum: () -> bool
|
|
176
|
-
def multiple_of: () -> Array[
|
|
177
|
-
def not_multiple_of: () -> Array[
|
|
182
|
+
def multiple_of: () -> Array[Numeric]
|
|
183
|
+
def not_multiple_of: () -> Array[Numeric]
|
|
178
184
|
def excludes_integers: () -> bool
|
|
179
185
|
def inspect: () -> String
|
|
180
186
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
181
187
|
end
|
|
182
188
|
|
|
183
|
-
# An integer
|
|
189
|
+
# An integer within `minimum`..`maximum`, a multiple of every `multiple_of` and of no `not_multiple_of` divisor.
|
|
184
190
|
class IntegerView
|
|
185
191
|
def minimum: () -> Integer?
|
|
186
192
|
def maximum: () -> Integer?
|
|
187
|
-
def multiple_of: () -> Array[
|
|
188
|
-
def not_multiple_of: () -> Array[
|
|
193
|
+
def multiple_of: () -> Array[Numeric]
|
|
194
|
+
def not_multiple_of: () -> Array[Numeric]
|
|
189
195
|
def inspect: () -> String
|
|
190
196
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
191
197
|
end
|
|
192
198
|
|
|
193
|
-
# An array value
|
|
199
|
+
# An array value's constraints.
|
|
194
200
|
class ArrayView
|
|
195
201
|
def min_items: () -> Integer?
|
|
196
202
|
def max_items: () -> Integer?
|
|
@@ -211,7 +217,7 @@ module JSONSchema
|
|
|
211
217
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
212
218
|
end
|
|
213
219
|
|
|
214
|
-
# An object value
|
|
220
|
+
# An object value's constraints.
|
|
215
221
|
class ObjectView
|
|
216
222
|
def min_properties: () -> Integer?
|
|
217
223
|
def max_properties: () -> Integer?
|
|
@@ -249,21 +255,21 @@ module JSONSchema
|
|
|
249
255
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
250
256
|
end
|
|
251
257
|
|
|
252
|
-
#
|
|
258
|
+
# Accepts the values `schema` rejects, keeping the references it names symbolic.
|
|
253
259
|
class NotView
|
|
254
260
|
def schema: () -> CanonicalSchema
|
|
255
261
|
def inspect: () -> String
|
|
256
262
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
257
263
|
end
|
|
258
264
|
|
|
259
|
-
#
|
|
265
|
+
# Accepts a value every branch accepts.
|
|
260
266
|
class AllOfView
|
|
261
267
|
def branches: () -> Array[CanonicalSchema]
|
|
262
268
|
def inspect: () -> String
|
|
263
269
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
264
270
|
end
|
|
265
271
|
|
|
266
|
-
#
|
|
272
|
+
# Accepts a value exactly one branch accepts.
|
|
267
273
|
class OneOfView
|
|
268
274
|
def branches: () -> Array[CanonicalSchema]
|
|
269
275
|
def inspect: () -> String
|
|
@@ -277,21 +283,21 @@ module JSONSchema
|
|
|
277
283
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
278
284
|
end
|
|
279
285
|
|
|
280
|
-
#
|
|
286
|
+
# Accepts a value any branch accepts.
|
|
281
287
|
class AnyOfView
|
|
282
288
|
def branches: () -> Array[CanonicalSchema]
|
|
283
289
|
def inspect: () -> String
|
|
284
290
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
285
291
|
end
|
|
286
292
|
|
|
287
|
-
# Exactly one
|
|
293
|
+
# Exactly one accepted value.
|
|
288
294
|
class ConstView
|
|
289
295
|
def value: () -> untyped
|
|
290
296
|
def inspect: () -> String
|
|
291
297
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
292
298
|
end
|
|
293
299
|
|
|
294
|
-
# A sorted, deduplicated finite set of
|
|
300
|
+
# A sorted, deduplicated finite set of accepted values.
|
|
295
301
|
class EnumView
|
|
296
302
|
def values: () -> Array[untyped]
|
|
297
303
|
def inspect: () -> String
|
|
@@ -324,25 +330,24 @@ module JSONSchema
|
|
|
324
330
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
325
331
|
end
|
|
326
332
|
|
|
327
|
-
# One part
|
|
328
|
-
# of its own under its pointer.
|
|
333
|
+
# One required part accepts no value; a subschema part is also reported under its own pointer.
|
|
329
334
|
class EmptyReason
|
|
330
335
|
def cause: () -> Cause
|
|
331
336
|
def inspect: () -> String
|
|
332
337
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
333
338
|
end
|
|
334
339
|
|
|
335
|
-
# Each part
|
|
340
|
+
# Each part accepts values; no value satisfies all of them together.
|
|
336
341
|
class ConflictReason
|
|
337
342
|
def causes: () -> Array[Cause]
|
|
338
343
|
def inspect: () -> String
|
|
339
344
|
def deconstruct_keys: (untyped keys) -> Hash[Symbol, untyped]
|
|
340
345
|
end
|
|
341
346
|
|
|
342
|
-
# Why a subschema
|
|
347
|
+
# Why a subschema accepts no value.
|
|
343
348
|
type unsatisfiable_reason = LiteralReason | EmptyReason | ConflictReason
|
|
344
349
|
|
|
345
|
-
# The subschemas that
|
|
350
|
+
# The subschemas that accept no value, keyed by JSON Pointer, with the reason for each.
|
|
346
351
|
#
|
|
347
352
|
# A pointer left out is not proven satisfiable: a document the canonical form does not model
|
|
348
353
|
# reports nothing, as `satisfiability` answers `:unknown`.
|
|
@@ -369,15 +374,6 @@ module JSONSchema
|
|
|
369
374
|
) -> Canonical::CanonicalSchema
|
|
370
375
|
|
|
371
376
|
# Create a validator with auto-detected draft version.
|
|
372
|
-
#
|
|
373
|
-
# @param schema The JSON Schema (Hash or JSON string)
|
|
374
|
-
# @param validate_formats Enable format validation
|
|
375
|
-
# @param ignore_unknown_formats Ignore unknown formats
|
|
376
|
-
# @param base_uri Base URI for reference resolution
|
|
377
|
-
# @param retriever Custom schema retriever proc
|
|
378
|
-
# @param mask Mask sensitive data in error messages
|
|
379
|
-
# @param formats Custom format validators (Hash of format_name => proc)
|
|
380
|
-
# @param keywords Custom keyword validators (Hash of keyword_name => class)
|
|
381
377
|
def self.validator_for: (
|
|
382
378
|
untyped schema,
|
|
383
379
|
?validate_formats: bool?,
|
|
@@ -424,6 +420,7 @@ module JSONSchema
|
|
|
424
420
|
?retriever: (^(String) -> untyped)?,
|
|
425
421
|
?registry: Registry?,
|
|
426
422
|
?base_uri: String?,
|
|
423
|
+
?http_options: HttpOptions?,
|
|
427
424
|
?offline: bool?
|
|
428
425
|
) -> Hash[String, untyped]
|
|
429
426
|
|
|
@@ -435,6 +432,7 @@ module JSONSchema
|
|
|
435
432
|
?retriever: (^(String) -> untyped)?,
|
|
436
433
|
?registry: Registry?,
|
|
437
434
|
?base_uri: String?,
|
|
435
|
+
?http_options: HttpOptions?,
|
|
438
436
|
?offline: bool?
|
|
439
437
|
) -> untyped
|
|
440
438
|
|
|
@@ -539,9 +537,27 @@ module JSONSchema
|
|
|
539
537
|
?offline: bool?
|
|
540
538
|
) -> Evaluation
|
|
541
539
|
|
|
542
|
-
# Reusable JSON Schema validator.
|
|
543
540
|
private
|
|
541
|
+
# Reusable JSON Schema validator.
|
|
544
542
|
class Validator
|
|
543
|
+
# The draft classes take the schema and the `validator_for` keyword arguments.
|
|
544
|
+
def initialize: (
|
|
545
|
+
untyped schema,
|
|
546
|
+
?validate_formats: bool?,
|
|
547
|
+
?ignore_unknown_formats: bool?,
|
|
548
|
+
?vocabularies: Array[String]?,
|
|
549
|
+
?base_uri: String?,
|
|
550
|
+
?retriever: (^(String) -> untyped)?,
|
|
551
|
+
?mask: String?,
|
|
552
|
+
?formats: Hash[String, ^(String) -> bool]?,
|
|
553
|
+
?keywords: Hash[String, Class]?,
|
|
554
|
+
?registry: Registry?,
|
|
555
|
+
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
556
|
+
?email_options: EmailOptions?,
|
|
557
|
+
?http_options: HttpOptions?,
|
|
558
|
+
?offline: bool?
|
|
559
|
+
) -> void
|
|
560
|
+
|
|
545
561
|
# Fast validation returning boolean.
|
|
546
562
|
def valid?: (untyped instance) -> bool
|
|
547
563
|
|
|
@@ -559,7 +575,7 @@ module JSONSchema
|
|
|
559
575
|
end
|
|
560
576
|
public
|
|
561
577
|
|
|
562
|
-
#
|
|
578
|
+
# Validators for every subschema, keyed by URI fragment such as `"#/$defs/User"`.
|
|
563
579
|
class ValidatorMap
|
|
564
580
|
def []: (::String pointer) -> Validator?
|
|
565
581
|
def fetch: (::String pointer) -> Validator
|
|
@@ -603,7 +619,6 @@ module JSONSchema
|
|
|
603
619
|
# Path to the failing schema location.
|
|
604
620
|
attr_reader schema_path: Array[String | Integer]
|
|
605
621
|
|
|
606
|
-
# Evaluation path.
|
|
607
622
|
attr_reader evaluation_path: Array[String | Integer]
|
|
608
623
|
|
|
609
624
|
# The specific kind of validation error.
|
|
@@ -612,15 +627,10 @@ module JSONSchema
|
|
|
612
627
|
# The failing instance value.
|
|
613
628
|
attr_reader instance: untyped
|
|
614
629
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
?schema_path: Array[String | Integer],
|
|
620
|
-
?evaluation_path: Array[String | Integer],
|
|
621
|
-
?kind: ValidationErrorKind?,
|
|
622
|
-
?instance: untyped
|
|
623
|
-
) -> void
|
|
630
|
+
# Absolute URI of the failing keyword; nil when its resource has no base URI.
|
|
631
|
+
attr_reader absolute_keyword_location: String?
|
|
632
|
+
|
|
633
|
+
def initialize: (?String message) -> void
|
|
624
634
|
|
|
625
635
|
def to_s: () -> String
|
|
626
636
|
def inspect: () -> String
|
|
@@ -632,13 +642,13 @@ module JSONSchema
|
|
|
632
642
|
# Hash code based on message, schema_path, and instance_path.
|
|
633
643
|
def hash: () -> Integer
|
|
634
644
|
|
|
635
|
-
#
|
|
645
|
+
# `instance_path` as a JSON Pointer (RFC 6901).
|
|
636
646
|
def instance_path_pointer: () -> String
|
|
637
647
|
|
|
638
|
-
#
|
|
648
|
+
# `schema_path` as a JSON Pointer (RFC 6901).
|
|
639
649
|
def schema_path_pointer: () -> String
|
|
640
650
|
|
|
641
|
-
#
|
|
651
|
+
# `evaluation_path` as a JSON Pointer (RFC 6901).
|
|
642
652
|
def evaluation_path_pointer: () -> String
|
|
643
653
|
end
|
|
644
654
|
|
|
@@ -675,7 +685,7 @@ module JSONSchema
|
|
|
675
685
|
def hierarchical: () -> Hash[Symbol, untyped]
|
|
676
686
|
|
|
677
687
|
# Collected annotations from all evaluated nodes.
|
|
678
|
-
# Each entry contains schemaLocation,
|
|
688
|
+
# Each entry contains schemaLocation, absoluteKeywordLocation, instanceLocation and annotations
|
|
679
689
|
def annotations: () -> Array[Hash[Symbol, untyped]]
|
|
680
690
|
|
|
681
691
|
# Collected errors from all evaluated nodes.
|
|
@@ -690,6 +700,7 @@ module JSONSchema
|
|
|
690
700
|
def base_uri: () -> String
|
|
691
701
|
def dynamic_scope: () -> Array[String]
|
|
692
702
|
def lookup: (String reference) -> Resolved
|
|
703
|
+
def lookup_dynamic_ref: (String reference) -> Resolved
|
|
693
704
|
end
|
|
694
705
|
|
|
695
706
|
# Resolved reference containing the dereferenced schema and its context.
|
|
@@ -703,10 +714,13 @@ module JSONSchema
|
|
|
703
714
|
class Registry
|
|
704
715
|
# Create a registry from URI/schema pairs.
|
|
705
716
|
# @param resources Array of [uri, schema] pairs
|
|
706
|
-
# @param draft
|
|
707
|
-
# @param retriever
|
|
717
|
+
# @param draft Default draft symbol, such as :draft7
|
|
718
|
+
# @param retriever Proc that fetches schemas for URIs not in `resources`
|
|
708
719
|
def initialize: (Array[[String, untyped]] resources, ?draft: draft?, ?retriever: (^(String) -> untyped)?) -> void
|
|
709
720
|
|
|
721
|
+
# Resolver for references against `base_uri`.
|
|
722
|
+
def resolver: (String base_uri) -> Resolver
|
|
723
|
+
|
|
710
724
|
def inspect: () -> String
|
|
711
725
|
end
|
|
712
726
|
|
|
@@ -731,7 +745,7 @@ module JSONSchema
|
|
|
731
745
|
# @param require_tld Require top-level domain (default: false)
|
|
732
746
|
# @param allow_domain_literal Allow domain literals like [127.0.0.1] (default: true)
|
|
733
747
|
# @param allow_display_text Allow display names like "Name <email>" (default: true)
|
|
734
|
-
# @param minimum_sub_domains Minimum number of
|
|
748
|
+
# @param minimum_sub_domains Minimum number of domain segments (default: nil)
|
|
735
749
|
def initialize: (
|
|
736
750
|
?require_tld: bool?,
|
|
737
751
|
?allow_domain_literal: bool?,
|
|
@@ -748,7 +762,7 @@ module JSONSchema
|
|
|
748
762
|
# Whether display text is allowed.
|
|
749
763
|
def allow_display_text: () -> bool
|
|
750
764
|
|
|
751
|
-
# Minimum number of
|
|
765
|
+
# Minimum number of domain segments.
|
|
752
766
|
def minimum_sub_domains: () -> Integer?
|
|
753
767
|
|
|
754
768
|
def inspect: () -> String
|
|
@@ -760,7 +774,15 @@ module JSONSchema
|
|
|
760
774
|
# Create regex engine options.
|
|
761
775
|
# @param size_limit Maximum compiled regex size in bytes
|
|
762
776
|
# @param dfa_size_limit Maximum DFA size in bytes
|
|
763
|
-
|
|
777
|
+
# @param syntax :ecma262 translates patterns for the engine, :engine passes them to it unchanged
|
|
778
|
+
def initialize: (
|
|
779
|
+
?size_limit: Integer?,
|
|
780
|
+
?dfa_size_limit: Integer?,
|
|
781
|
+
?syntax: (:ecma262 | :engine)?
|
|
782
|
+
) -> void
|
|
783
|
+
|
|
784
|
+
# Syntax patterns are written in.
|
|
785
|
+
def syntax: () -> (:ecma262 | :engine)
|
|
764
786
|
|
|
765
787
|
# Maximum compiled regex size.
|
|
766
788
|
def size_limit: () -> Integer?
|
|
@@ -772,18 +794,23 @@ module JSONSchema
|
|
|
772
794
|
def to_s: () -> String
|
|
773
795
|
end
|
|
774
796
|
|
|
775
|
-
#
|
|
797
|
+
# fancy-regex engine options: backtracking, with lookaround and backreferences.
|
|
776
798
|
class FancyRegexOptions
|
|
777
799
|
# Create fancy regex engine options.
|
|
778
800
|
# @param backtrack_limit Maximum backtracking steps
|
|
779
801
|
# @param size_limit Maximum compiled regex size
|
|
780
802
|
# @param dfa_size_limit Maximum DFA size
|
|
803
|
+
# @param syntax :ecma262 translates patterns for the engine, :engine passes them to it unchanged
|
|
781
804
|
def initialize: (
|
|
782
805
|
?backtrack_limit: Integer?,
|
|
783
806
|
?size_limit: Integer?,
|
|
784
|
-
?dfa_size_limit: Integer
|
|
807
|
+
?dfa_size_limit: Integer?,
|
|
808
|
+
?syntax: (:ecma262 | :engine)?
|
|
785
809
|
) -> void
|
|
786
810
|
|
|
811
|
+
# Syntax patterns are written in.
|
|
812
|
+
def syntax: () -> (:ecma262 | :engine)
|
|
813
|
+
|
|
787
814
|
# Maximum backtracking steps.
|
|
788
815
|
def backtrack_limit: () -> Integer?
|
|
789
816
|
|
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.
|
|
4
|
+
version: 0.62.0
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Dmitry Dygalo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bigdecimal
|
|
@@ -56,7 +56,7 @@ metadata:
|
|
|
56
56
|
homepage_uri: https://github.com/Stranger6667/jsonschema/tree/master/crates/jsonschema-rb
|
|
57
57
|
source_code_uri: https://github.com/Stranger6667/jsonschema
|
|
58
58
|
changelog_uri: https://github.com/Stranger6667/jsonschema/blob/master/crates/jsonschema-rb/CHANGELOG.md
|
|
59
|
-
documentation_uri: https://github.com/Stranger6667/jsonschema/blob/ruby-v0.
|
|
59
|
+
documentation_uri: https://github.com/Stranger6667/jsonschema/blob/ruby-v0.62.0/crates/jsonschema-rb/README.md
|
|
60
60
|
bug_tracker_uri: https://github.com/Stranger6667/jsonschema/issues
|
|
61
61
|
funding_uri: https://github.com/sponsors/Stranger6667
|
|
62
62
|
rubygems_mfa_required: 'true'
|