jsonschema_rs 0.62.0-aarch64-linux → 0.63.1-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 +28 -1
- data/README.md +30 -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
- data/sig/jsonschema.rbs +54 -7
- 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: 8d3fb22f38c7cbf4a38f86f891d0353b99a9e87721b1a94add1a3be210b6c3f2
|
|
4
|
+
data.tar.gz: f7ddba356fab2ac8c16f197a4c66e753eeef6aaecd80b7c511405b818c718828
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb8c5d41af63ed629d5d68b40b6c53101621fc284c7ea5a4a5eec3ff7ca61eed6854619b83602b6f4d5937522924ed3d268e0e0ebd01def9bc418e8c1e72cce8
|
|
7
|
+
data.tar.gz: da49ad11b4abaf8b981564abaffd96324bc149eb667c0d701690031bc417de11690702a67b47a6597bf4a4ed57e32e79e32dee545cd5e9103a30138944ddf129
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.63.1] - 2026-11-23
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `JSONSchema.known_formats`, the names of the formats with a check under a draft, built in and registered.
|
|
10
|
+
|
|
11
|
+
## [0.63.0] - 2026-11-22
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `JsonTextValidator`, validating instances given as JSON text without building Ruby objects for them.
|
|
16
|
+
- `JSONSchema.number_format`, a custom `format` check that reads numbers.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- `$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.
|
|
21
|
+
- `$ref` to a `json-schema.org` URI with no bundled meta-schema, such as `http://json-schema.org/draft-03/schema#`, never retrieved.
|
|
22
|
+
- Error messages for an empty `enum` ending after "is not one of" instead of naming the empty `enum`.
|
|
23
|
+
- `HttpOptions.new(ca_cert: ...)` accepting a file without certificates.
|
|
24
|
+
- Draft 4 schemas with an empty `enum`, or one with equal members such as `[0, 0.0]`, passing the meta-schema check.
|
|
25
|
+
- `HttpOptions.new(ca_cert: ...)` reporting invalid PEM as an HTTP client build error instead of a certificate parse error that names the file.
|
|
26
|
+
- Custom keyword `iter_errors` returning a non-exception producing a message prefixed with `RuntimeError: ` and no `cause`.
|
|
27
|
+
- Named backreferences such as `(?<n>x)\k<n>` failing to build in `pattern`, `patternProperties` and `propertyNames`.
|
|
28
|
+
- 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.
|
|
29
|
+
|
|
5
30
|
## [0.62.0] - 2026-11-21
|
|
6
31
|
|
|
7
32
|
### Added
|
|
@@ -854,7 +879,9 @@
|
|
|
854
879
|
|
|
855
880
|
- Initial public release
|
|
856
881
|
|
|
857
|
-
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.
|
|
882
|
+
[Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.63.1...HEAD
|
|
883
|
+
[0.63.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.63.0...ruby-v0.63.1
|
|
884
|
+
[0.63.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.62.0...ruby-v0.63.0
|
|
858
885
|
[0.62.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.2...ruby-v0.62.0
|
|
859
886
|
[0.61.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.1...ruby-v0.61.2
|
|
860
887
|
[0.61.1]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.0...ruby-v0.61.1
|
data/README.md
CHANGED
|
@@ -119,6 +119,22 @@ validator = JSONSchema::Draft7Validator.new(schema)
|
|
|
119
119
|
|
|
120
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
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
|
+
|
|
122
138
|
### Custom format validators
|
|
123
139
|
|
|
124
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:
|
|
@@ -133,6 +149,20 @@ validator = JSONSchema.validator_for(
|
|
|
133
149
|
)
|
|
134
150
|
```
|
|
135
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
|
+
|
|
160
|
+
`JSONSchema.known_formats` lists the formats with a check under a draft, built in and from `formats`:
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
JSONSchema.known_formats(:draft202012, formats: { "phone" => phone_format }).include?("phone") # => true
|
|
164
|
+
```
|
|
165
|
+
|
|
136
166
|
### Custom keyword validators
|
|
137
167
|
|
|
138
168
|
```ruby
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/jsonschema/version.rb
CHANGED
data/sig/jsonschema.rbs
CHANGED
|
@@ -373,6 +373,17 @@ module JSONSchema
|
|
|
373
373
|
?base_uri: String?
|
|
374
374
|
) -> Canonical::CanonicalSchema
|
|
375
375
|
|
|
376
|
+
# A `format` check that reads numbers, for the `formats` option; other instances pass it.
|
|
377
|
+
def self.number_format: (^(Numeric) -> bool check) -> NumberFormat
|
|
378
|
+
|
|
379
|
+
# A `format` check that reads numbers, made by `JSONSchema.number_format`.
|
|
380
|
+
class NumberFormat
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
# The names of the formats with a check under `draft`, sorted and without duplicates: the
|
|
384
|
+
# built-in formats and those in `formats`.
|
|
385
|
+
def self.known_formats: (draft draft, ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?) -> Array[String]
|
|
386
|
+
|
|
376
387
|
# Create a validator with auto-detected draft version.
|
|
377
388
|
def self.validator_for: (
|
|
378
389
|
untyped schema,
|
|
@@ -382,7 +393,7 @@ module JSONSchema
|
|
|
382
393
|
?base_uri: String?,
|
|
383
394
|
?retriever: (^(String) -> untyped)?,
|
|
384
395
|
?mask: String?,
|
|
385
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
396
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
386
397
|
?keywords: Hash[String, Class]?,
|
|
387
398
|
?registry: Registry?,
|
|
388
399
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -451,7 +462,7 @@ module JSONSchema
|
|
|
451
462
|
?base_uri: String?,
|
|
452
463
|
?retriever: (^(String) -> untyped)?,
|
|
453
464
|
?mask: String?,
|
|
454
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
465
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
455
466
|
?keywords: Hash[String, Class]?,
|
|
456
467
|
?registry: Registry?,
|
|
457
468
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -471,7 +482,7 @@ module JSONSchema
|
|
|
471
482
|
?base_uri: String?,
|
|
472
483
|
?retriever: (^(String) -> untyped)?,
|
|
473
484
|
?mask: String?,
|
|
474
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
485
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
475
486
|
?keywords: Hash[String, Class]?,
|
|
476
487
|
?registry: Registry?,
|
|
477
488
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -491,7 +502,7 @@ module JSONSchema
|
|
|
491
502
|
?base_uri: String?,
|
|
492
503
|
?retriever: (^(String) -> untyped)?,
|
|
493
504
|
?mask: String?,
|
|
494
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
505
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
495
506
|
?keywords: Hash[String, Class]?,
|
|
496
507
|
?registry: Registry?,
|
|
497
508
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -509,7 +520,7 @@ module JSONSchema
|
|
|
509
520
|
?base_uri: String?,
|
|
510
521
|
?retriever: (^(String) -> untyped)?,
|
|
511
522
|
?mask: String?,
|
|
512
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
523
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
513
524
|
?keywords: Hash[String, Class]?,
|
|
514
525
|
?registry: Registry?,
|
|
515
526
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -528,7 +539,7 @@ module JSONSchema
|
|
|
528
539
|
?vocabularies: Array[String]?,
|
|
529
540
|
?base_uri: String?,
|
|
530
541
|
?retriever: (^(String) -> untyped)?,
|
|
531
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
542
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
532
543
|
?keywords: Hash[String, Class]?,
|
|
533
544
|
?registry: Registry?,
|
|
534
545
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -549,7 +560,7 @@ module JSONSchema
|
|
|
549
560
|
?base_uri: String?,
|
|
550
561
|
?retriever: (^(String) -> untyped)?,
|
|
551
562
|
?mask: String?,
|
|
552
|
-
?formats: Hash[String, ^(String) -> bool]?,
|
|
563
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
553
564
|
?keywords: Hash[String, Class]?,
|
|
554
565
|
?registry: Registry?,
|
|
555
566
|
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
@@ -573,6 +584,42 @@ module JSONSchema
|
|
|
573
584
|
|
|
574
585
|
def inspect: () -> String
|
|
575
586
|
end
|
|
587
|
+
|
|
588
|
+
# Validates instances given as JSON text, without building Ruby objects for them.
|
|
589
|
+
class JsonTextValidator
|
|
590
|
+
def initialize: (
|
|
591
|
+
untyped schema,
|
|
592
|
+
?draft: draft?,
|
|
593
|
+
?validate_formats: bool?,
|
|
594
|
+
?ignore_unknown_formats: bool?,
|
|
595
|
+
?vocabularies: Array[String]?,
|
|
596
|
+
?base_uri: String?,
|
|
597
|
+
?retriever: (^(String) -> untyped)?,
|
|
598
|
+
?mask: String?,
|
|
599
|
+
?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
|
|
600
|
+
?keywords: Hash[String, Class]?,
|
|
601
|
+
?registry: Registry?,
|
|
602
|
+
?pattern_options: (RegexOptions | FancyRegexOptions)?,
|
|
603
|
+
?email_options: EmailOptions?,
|
|
604
|
+
?http_options: HttpOptions?,
|
|
605
|
+
?offline: bool?
|
|
606
|
+
) -> void
|
|
607
|
+
|
|
608
|
+
# Whether the JSON text holds a valid document.
|
|
609
|
+
def valid?: (String text) -> bool
|
|
610
|
+
|
|
611
|
+
# Raise on the first error of the document in the JSON text.
|
|
612
|
+
def validate!: (String text) -> nil
|
|
613
|
+
|
|
614
|
+
# Iterate validation errors. Returns Array when no block given, nil when block given.
|
|
615
|
+
def each_error: (String text) -> Array[ValidationError]
|
|
616
|
+
| (String text) { (ValidationError) -> void } -> nil
|
|
617
|
+
|
|
618
|
+
# Evaluate the document in the JSON text and return structured output.
|
|
619
|
+
def evaluate: (String text) -> Evaluation
|
|
620
|
+
|
|
621
|
+
def inspect: () -> String
|
|
622
|
+
end
|
|
576
623
|
public
|
|
577
624
|
|
|
578
625
|
# Validators for every subschema, keyed by URI fragment such as `"#/$defs/User"`.
|
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.63.1
|
|
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-11-
|
|
11
|
+
date: 2026-11-23 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.63.1/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'
|