jsonschema_rs 0.62.0-x86_64-linux → 0.63.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e86780129b9c55d4bc1dbef93849d00a3b2f74f778e788cf449cdba44c5e686e
4
- data.tar.gz: 64e3123a73e29a570ece8da1d4da7a959b365a031dac34515c474695b6f9d05f
3
+ metadata.gz: 1825db9327a8b87ba8f8f3b1a65ac219859e642390e2a8b38f20ee2bb5ce5804
4
+ data.tar.gz: 3f3a9d7f0999e1ea07a76bad0b41a744427a7d6b1ecc8166b70a38bd67ab2c27
5
5
  SHA512:
6
- metadata.gz: 0a6f38576f907dc0877a16c2d680f7db511b6c4b8fb91470359911d90f219eaa431cda0ac689eb1b586059ecdc84c102aa85939fdf6d39d22c0d87628c11d101
7
- data.tar.gz: 59f77d624b5869731a80c565dc0e375e5f9b6eda9d6af2a12e9ea98c477dec73b8686459faa18d55f2825a082d60167540c2be0cd2173b1fe96283d0b2c09965
6
+ metadata.gz: b9412ddaacac54d282e409cd28bcbdc9f6abe8a53802d8bc5407cc074b5239356e3ca4f22f9e768dc5907ace068fd66dc0b3683c60f8b6a0c0992d7da4de9da6
7
+ data.tar.gz: c60b43d1e4ad011a2220ce1e7752beccc1ecc2026801296ae02800ad2468c9889512926fd3dac8ffbe151913e2acd7f562ad85db87d9bf5ac5ed123546e968ad
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
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
+
5
24
  ## [0.62.0] - 2026-11-21
6
25
 
7
26
  ### Added
@@ -854,7 +873,8 @@
854
873
 
855
874
  - Initial public release
856
875
 
857
- [Unreleased]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.62.0...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
858
878
  [0.62.0]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.2...ruby-v0.62.0
859
879
  [0.61.2]: https://github.com/Stranger6667/jsonschema/compare/ruby-v0.61.1...ruby-v0.61.2
860
880
  [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,14 @@ 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
+
136
160
  ### Custom keyword validators
137
161
 
138
162
  ```ruby
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSchema
4
- VERSION = "0.62.0"
4
+ VERSION = "0.63.0"
5
5
  end
data/sig/jsonschema.rbs CHANGED
@@ -373,6 +373,13 @@ 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
+
376
383
  # Create a validator with auto-detected draft version.
377
384
  def self.validator_for: (
378
385
  untyped schema,
@@ -382,7 +389,7 @@ module JSONSchema
382
389
  ?base_uri: String?,
383
390
  ?retriever: (^(String) -> untyped)?,
384
391
  ?mask: String?,
385
- ?formats: Hash[String, ^(String) -> bool]?,
392
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
386
393
  ?keywords: Hash[String, Class]?,
387
394
  ?registry: Registry?,
388
395
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -451,7 +458,7 @@ module JSONSchema
451
458
  ?base_uri: String?,
452
459
  ?retriever: (^(String) -> untyped)?,
453
460
  ?mask: String?,
454
- ?formats: Hash[String, ^(String) -> bool]?,
461
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
455
462
  ?keywords: Hash[String, Class]?,
456
463
  ?registry: Registry?,
457
464
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -471,7 +478,7 @@ module JSONSchema
471
478
  ?base_uri: String?,
472
479
  ?retriever: (^(String) -> untyped)?,
473
480
  ?mask: String?,
474
- ?formats: Hash[String, ^(String) -> bool]?,
481
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
475
482
  ?keywords: Hash[String, Class]?,
476
483
  ?registry: Registry?,
477
484
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -491,7 +498,7 @@ module JSONSchema
491
498
  ?base_uri: String?,
492
499
  ?retriever: (^(String) -> untyped)?,
493
500
  ?mask: String?,
494
- ?formats: Hash[String, ^(String) -> bool]?,
501
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
495
502
  ?keywords: Hash[String, Class]?,
496
503
  ?registry: Registry?,
497
504
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -509,7 +516,7 @@ module JSONSchema
509
516
  ?base_uri: String?,
510
517
  ?retriever: (^(String) -> untyped)?,
511
518
  ?mask: String?,
512
- ?formats: Hash[String, ^(String) -> bool]?,
519
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
513
520
  ?keywords: Hash[String, Class]?,
514
521
  ?registry: Registry?,
515
522
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -528,7 +535,7 @@ module JSONSchema
528
535
  ?vocabularies: Array[String]?,
529
536
  ?base_uri: String?,
530
537
  ?retriever: (^(String) -> untyped)?,
531
- ?formats: Hash[String, ^(String) -> bool]?,
538
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
532
539
  ?keywords: Hash[String, Class]?,
533
540
  ?registry: Registry?,
534
541
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -549,7 +556,7 @@ module JSONSchema
549
556
  ?base_uri: String?,
550
557
  ?retriever: (^(String) -> untyped)?,
551
558
  ?mask: String?,
552
- ?formats: Hash[String, ^(String) -> bool]?,
559
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
553
560
  ?keywords: Hash[String, Class]?,
554
561
  ?registry: Registry?,
555
562
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -573,6 +580,42 @@ module JSONSchema
573
580
 
574
581
  def inspect: () -> String
575
582
  end
583
+
584
+ # Validates instances given as JSON text, without building Ruby objects for them.
585
+ class JsonTextValidator
586
+ def initialize: (
587
+ untyped schema,
588
+ ?draft: draft?,
589
+ ?validate_formats: bool?,
590
+ ?ignore_unknown_formats: bool?,
591
+ ?vocabularies: Array[String]?,
592
+ ?base_uri: String?,
593
+ ?retriever: (^(String) -> untyped)?,
594
+ ?mask: String?,
595
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
596
+ ?keywords: Hash[String, Class]?,
597
+ ?registry: Registry?,
598
+ ?pattern_options: (RegexOptions | FancyRegexOptions)?,
599
+ ?email_options: EmailOptions?,
600
+ ?http_options: HttpOptions?,
601
+ ?offline: bool?
602
+ ) -> void
603
+
604
+ # Whether the JSON text holds a valid document.
605
+ def valid?: (String text) -> bool
606
+
607
+ # Raise on the first error of the document in the JSON text.
608
+ def validate!: (String text) -> nil
609
+
610
+ # Iterate validation errors. Returns Array when no block given, nil when block given.
611
+ def each_error: (String text) -> Array[ValidationError]
612
+ | (String text) { (ValidationError) -> void } -> nil
613
+
614
+ # Evaluate the document in the JSON text and return structured output.
615
+ def evaluate: (String text) -> Evaluation
616
+
617
+ def inspect: () -> String
618
+ end
576
619
  public
577
620
 
578
621
  # 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.62.0
4
+ version: 0.63.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-21 00:00:00.000000000 Z
11
+ date: 2026-11-22 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.62.0/crates/jsonschema-rb/README.md
59
+ documentation_uri: https://github.com/Stranger6667/jsonschema/blob/ruby-v0.63.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'