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.
data/sig/jsonschema.rbs CHANGED
@@ -1,9 +1,15 @@
1
- # Type definitions for jsonschema gem
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
- # What stopped a run from modeling a document.
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 admits every value another does. Only `:yes` proves containment: test
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 admits nothing: test for `:no`,
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: schemas accepting the same values share one 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
- # Matches any value.
138
+ # Accepts every value.
133
139
  class TrueView
134
140
  end
135
141
 
136
- # Matches no value.
142
+ # Rejects every value.
137
143
  class FalseView
138
144
  end
139
145
 
140
- # A value matches iff its JSON type is in the set.
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
- # A value matches iff its JSON type is `type_name` and it satisfies `body`.
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 value within a length window, matching every pattern.
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: () -> (Integer | Float)?
178
+ def minimum: () -> Numeric?
173
179
  def exclusive_minimum: () -> bool
174
- def maximum: () -> (Integer | Float)?
180
+ def maximum: () -> Numeric?
175
181
  def exclusive_maximum: () -> bool
176
- def multiple_of: () -> Array[Integer | Float]
177
- def not_multiple_of: () -> Array[Integer | Float]
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 value within a closed interval, optionally a multiple of a divisor.
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[Integer | Float]
188
- def not_multiple_of: () -> Array[Integer | Float]
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 whose length is within a window.
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 whose property count is within a window.
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
- # The complement of an opaque schema.
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
- # A value matches iff every branch matches.
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
- # A value matches iff exactly one branch matches.
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
- # A value matches iff at least one branch matches.
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 admitted value.
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 admitted values.
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 every value must satisfy admits nothing by itself. A subschema part has a reason
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 admits values; no value satisfies all of them together.
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 admits no value.
347
+ # Why a subschema accepts no value.
343
348
  type unsatisfiable_reason = LiteralReason | EmptyReason | ConflictReason
344
349
 
345
- # The subschemas that admit no value, by JSON Pointer, each with why.
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`.
@@ -368,16 +373,14 @@ module JSONSchema
368
373
  ?base_uri: String?
369
374
  ) -> Canonical::CanonicalSchema
370
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
+
371
383
  # 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
384
  def self.validator_for: (
382
385
  untyped schema,
383
386
  ?validate_formats: bool?,
@@ -386,7 +389,7 @@ module JSONSchema
386
389
  ?base_uri: String?,
387
390
  ?retriever: (^(String) -> untyped)?,
388
391
  ?mask: String?,
389
- ?formats: Hash[String, ^(String) -> bool]?,
392
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
390
393
  ?keywords: Hash[String, Class]?,
391
394
  ?registry: Registry?,
392
395
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -424,6 +427,7 @@ module JSONSchema
424
427
  ?retriever: (^(String) -> untyped)?,
425
428
  ?registry: Registry?,
426
429
  ?base_uri: String?,
430
+ ?http_options: HttpOptions?,
427
431
  ?offline: bool?
428
432
  ) -> Hash[String, untyped]
429
433
 
@@ -435,6 +439,7 @@ module JSONSchema
435
439
  ?retriever: (^(String) -> untyped)?,
436
440
  ?registry: Registry?,
437
441
  ?base_uri: String?,
442
+ ?http_options: HttpOptions?,
438
443
  ?offline: bool?
439
444
  ) -> untyped
440
445
 
@@ -453,7 +458,7 @@ module JSONSchema
453
458
  ?base_uri: String?,
454
459
  ?retriever: (^(String) -> untyped)?,
455
460
  ?mask: String?,
456
- ?formats: Hash[String, ^(String) -> bool]?,
461
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
457
462
  ?keywords: Hash[String, Class]?,
458
463
  ?registry: Registry?,
459
464
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -473,7 +478,7 @@ module JSONSchema
473
478
  ?base_uri: String?,
474
479
  ?retriever: (^(String) -> untyped)?,
475
480
  ?mask: String?,
476
- ?formats: Hash[String, ^(String) -> bool]?,
481
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
477
482
  ?keywords: Hash[String, Class]?,
478
483
  ?registry: Registry?,
479
484
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -493,7 +498,7 @@ module JSONSchema
493
498
  ?base_uri: String?,
494
499
  ?retriever: (^(String) -> untyped)?,
495
500
  ?mask: String?,
496
- ?formats: Hash[String, ^(String) -> bool]?,
501
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
497
502
  ?keywords: Hash[String, Class]?,
498
503
  ?registry: Registry?,
499
504
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -511,7 +516,7 @@ module JSONSchema
511
516
  ?base_uri: String?,
512
517
  ?retriever: (^(String) -> untyped)?,
513
518
  ?mask: String?,
514
- ?formats: Hash[String, ^(String) -> bool]?,
519
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
515
520
  ?keywords: Hash[String, Class]?,
516
521
  ?registry: Registry?,
517
522
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -530,7 +535,7 @@ module JSONSchema
530
535
  ?vocabularies: Array[String]?,
531
536
  ?base_uri: String?,
532
537
  ?retriever: (^(String) -> untyped)?,
533
- ?formats: Hash[String, ^(String) -> bool]?,
538
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
534
539
  ?keywords: Hash[String, Class]?,
535
540
  ?registry: Registry?,
536
541
  ?pattern_options: (RegexOptions | FancyRegexOptions)?,
@@ -539,9 +544,27 @@ module JSONSchema
539
544
  ?offline: bool?
540
545
  ) -> Evaluation
541
546
 
542
- # Reusable JSON Schema validator.
543
547
  private
548
+ # Reusable JSON Schema validator.
544
549
  class Validator
550
+ # The draft classes take the schema and the `validator_for` keyword arguments.
551
+ def initialize: (
552
+ untyped schema,
553
+ ?validate_formats: bool?,
554
+ ?ignore_unknown_formats: bool?,
555
+ ?vocabularies: Array[String]?,
556
+ ?base_uri: String?,
557
+ ?retriever: (^(String) -> untyped)?,
558
+ ?mask: String?,
559
+ ?formats: Hash[String, (^(String) -> bool) | NumberFormat]?,
560
+ ?keywords: Hash[String, Class]?,
561
+ ?registry: Registry?,
562
+ ?pattern_options: (RegexOptions | FancyRegexOptions)?,
563
+ ?email_options: EmailOptions?,
564
+ ?http_options: HttpOptions?,
565
+ ?offline: bool?
566
+ ) -> void
567
+
545
568
  # Fast validation returning boolean.
546
569
  def valid?: (untyped instance) -> bool
547
570
 
@@ -557,9 +580,45 @@ module JSONSchema
557
580
 
558
581
  def inspect: () -> String
559
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
560
619
  public
561
620
 
562
- # Map of validators for all sub-schemas in a JSON Schema, keyed by JSON Pointer.
621
+ # Validators for every subschema, keyed by URI fragment such as `"#/$defs/User"`.
563
622
  class ValidatorMap
564
623
  def []: (::String pointer) -> Validator?
565
624
  def fetch: (::String pointer) -> Validator
@@ -603,7 +662,6 @@ module JSONSchema
603
662
  # Path to the failing schema location.
604
663
  attr_reader schema_path: Array[String | Integer]
605
664
 
606
- # Evaluation path.
607
665
  attr_reader evaluation_path: Array[String | Integer]
608
666
 
609
667
  # The specific kind of validation error.
@@ -612,15 +670,10 @@ module JSONSchema
612
670
  # The failing instance value.
613
671
  attr_reader instance: untyped
614
672
 
615
- def initialize: (
616
- message: String,
617
- ?verbose_message: String?,
618
- ?instance_path: Array[String | Integer],
619
- ?schema_path: Array[String | Integer],
620
- ?evaluation_path: Array[String | Integer],
621
- ?kind: ValidationErrorKind?,
622
- ?instance: untyped
623
- ) -> void
673
+ # Absolute URI of the failing keyword; nil when its resource has no base URI.
674
+ attr_reader absolute_keyword_location: String?
675
+
676
+ def initialize: (?String message) -> void
624
677
 
625
678
  def to_s: () -> String
626
679
  def inspect: () -> String
@@ -632,13 +685,13 @@ module JSONSchema
632
685
  # Hash code based on message, schema_path, and instance_path.
633
686
  def hash: () -> Integer
634
687
 
635
- # Convert instance_path to JSON Pointer format (RFC 6901).
688
+ # `instance_path` as a JSON Pointer (RFC 6901).
636
689
  def instance_path_pointer: () -> String
637
690
 
638
- # Convert schema_path to JSON Pointer format (RFC 6901).
691
+ # `schema_path` as a JSON Pointer (RFC 6901).
639
692
  def schema_path_pointer: () -> String
640
693
 
641
- # Evaluation path as JSON Pointer string (RFC 6901), pre-computed in Rust.
694
+ # `evaluation_path` as a JSON Pointer (RFC 6901).
642
695
  def evaluation_path_pointer: () -> String
643
696
  end
644
697
 
@@ -675,7 +728,7 @@ module JSONSchema
675
728
  def hierarchical: () -> Hash[Symbol, untyped]
676
729
 
677
730
  # Collected annotations from all evaluated nodes.
678
- # Each entry contains schemaLocation, instanceLocation, and annotations
731
+ # Each entry contains schemaLocation, absoluteKeywordLocation, instanceLocation and annotations
679
732
  def annotations: () -> Array[Hash[Symbol, untyped]]
680
733
 
681
734
  # Collected errors from all evaluated nodes.
@@ -690,6 +743,7 @@ module JSONSchema
690
743
  def base_uri: () -> String
691
744
  def dynamic_scope: () -> Array[String]
692
745
  def lookup: (String reference) -> Resolved
746
+ def lookup_dynamic_ref: (String reference) -> Resolved
693
747
  end
694
748
 
695
749
  # Resolved reference containing the dereferenced schema and its context.
@@ -703,10 +757,13 @@ module JSONSchema
703
757
  class Registry
704
758
  # Create a registry from URI/schema pairs.
705
759
  # @param resources Array of [uri, schema] pairs
706
- # @param draft Optional draft version constant
707
- # @param retriever Custom schema retriever proc for dynamic resolution
760
+ # @param draft Default draft symbol, such as :draft7
761
+ # @param retriever Proc that fetches schemas for URIs not in `resources`
708
762
  def initialize: (Array[[String, untyped]] resources, ?draft: draft?, ?retriever: (^(String) -> untyped)?) -> void
709
763
 
764
+ # Resolver for references against `base_uri`.
765
+ def resolver: (String base_uri) -> Resolver
766
+
710
767
  def inspect: () -> String
711
768
  end
712
769
 
@@ -731,7 +788,7 @@ module JSONSchema
731
788
  # @param require_tld Require top-level domain (default: false)
732
789
  # @param allow_domain_literal Allow domain literals like [127.0.0.1] (default: true)
733
790
  # @param allow_display_text Allow display names like "Name <email>" (default: true)
734
- # @param minimum_sub_domains Minimum number of subdomains required (default: nil)
791
+ # @param minimum_sub_domains Minimum number of domain segments (default: nil)
735
792
  def initialize: (
736
793
  ?require_tld: bool?,
737
794
  ?allow_domain_literal: bool?,
@@ -748,7 +805,7 @@ module JSONSchema
748
805
  # Whether display text is allowed.
749
806
  def allow_display_text: () -> bool
750
807
 
751
- # Minimum number of subdomains.
808
+ # Minimum number of domain segments.
752
809
  def minimum_sub_domains: () -> Integer?
753
810
 
754
811
  def inspect: () -> String
@@ -760,7 +817,15 @@ module JSONSchema
760
817
  # Create regex engine options.
761
818
  # @param size_limit Maximum compiled regex size in bytes
762
819
  # @param dfa_size_limit Maximum DFA size in bytes
763
- def initialize: (?size_limit: Integer?, ?dfa_size_limit: Integer?) -> void
820
+ # @param syntax :ecma262 translates patterns for the engine, :engine passes them to it unchanged
821
+ def initialize: (
822
+ ?size_limit: Integer?,
823
+ ?dfa_size_limit: Integer?,
824
+ ?syntax: (:ecma262 | :engine)?
825
+ ) -> void
826
+
827
+ # Syntax patterns are written in.
828
+ def syntax: () -> (:ecma262 | :engine)
764
829
 
765
830
  # Maximum compiled regex size.
766
831
  def size_limit: () -> Integer?
@@ -772,18 +837,23 @@ module JSONSchema
772
837
  def to_s: () -> String
773
838
  end
774
839
 
775
- # Fancy regex engine options (ECMA-262 patterns).
840
+ # fancy-regex engine options: backtracking, with lookaround and backreferences.
776
841
  class FancyRegexOptions
777
842
  # Create fancy regex engine options.
778
843
  # @param backtrack_limit Maximum backtracking steps
779
844
  # @param size_limit Maximum compiled regex size
780
845
  # @param dfa_size_limit Maximum DFA size
846
+ # @param syntax :ecma262 translates patterns for the engine, :engine passes them to it unchanged
781
847
  def initialize: (
782
848
  ?backtrack_limit: Integer?,
783
849
  ?size_limit: Integer?,
784
- ?dfa_size_limit: Integer?
850
+ ?dfa_size_limit: Integer?,
851
+ ?syntax: (:ecma262 | :engine)?
785
852
  ) -> void
786
853
 
854
+ # Syntax patterns are written in.
855
+ def syntax: () -> (:ecma262 | :engine)
856
+
787
857
  # Maximum backtracking steps.
788
858
  def backtrack_limit: () -> Integer?
789
859
 
data/src/canonical.rs CHANGED
@@ -343,7 +343,7 @@ impl RawView {
343
343
  }
344
344
  }
345
345
 
346
- /// Matches any value.
346
+ /// Accepts every value.
347
347
  #[derive(magnus::TypedData)]
348
348
  #[magnus(class = "JSONSchema::Canonical::TrueView", free_immediately)]
349
349
  pub struct TrueView;
@@ -356,7 +356,7 @@ impl TrueView {
356
356
 
357
357
  impl DataTypeFunctions for TrueView {}
358
358
 
359
- /// Matches no value.
359
+ /// Rejects every value.
360
360
  #[derive(magnus::TypedData)]
361
361
  #[magnus(class = "JSONSchema::Canonical::FalseView", free_immediately)]
362
362
  pub struct FalseView;
@@ -369,7 +369,7 @@ impl FalseView {
369
369
 
370
370
  impl DataTypeFunctions for FalseView {}
371
371
 
372
- /// A value matches iff its JSON type is in `types`.
372
+ /// Accepts a value whose JSON type is in `types`.
373
373
  #[derive(magnus::TypedData)]
374
374
  #[magnus(class = "JSONSchema::Canonical::MultiTypeView", free_immediately)]
375
375
  pub struct MultiTypeView {
@@ -401,7 +401,7 @@ impl MultiTypeView {
401
401
  }
402
402
  }
403
403
 
404
- /// A value matches iff its JSON type is `type_name` *and* it satisfies `body`.
404
+ /// Accepts a value of JSON type `type_name` that `body` accepts.
405
405
  #[derive(magnus::TypedData)]
406
406
  #[magnus(class = "JSONSchema::Canonical::TypedGroupView", free_immediately)]
407
407
  pub struct TypedGroupView {
@@ -465,7 +465,8 @@ fn strings_to_ruby(ruby: &Ruby, values: &[String]) -> Result<Value, Error> {
465
465
  Ok(array.as_value())
466
466
  }
467
467
 
468
- /// A string value within a length window, matching every required facet and no barred one.
468
+ /// A string within `min_length`..`max_length`, matching every listed constraint and none of the
469
+ /// excluded ones.
469
470
  #[derive(magnus::TypedData)]
470
471
  #[magnus(class = "JSONSchema::Canonical::StringView", free_immediately)]
471
472
  pub struct StringView {
@@ -646,7 +647,8 @@ impl NumberView {
646
647
  }
647
648
  }
648
649
 
649
- /// An integer value within a closed interval, optionally a multiple of a divisor.
650
+ /// An integer within `minimum`..`maximum`, a multiple of every `multiple_of` and of no
651
+ /// `not_multiple_of` divisor.
650
652
  #[derive(magnus::TypedData)]
651
653
  #[magnus(class = "JSONSchema::Canonical::IntegerView", free_immediately)]
652
654
  pub struct IntegerView {
@@ -850,8 +852,6 @@ impl ContainsView {
850
852
  }
851
853
  }
852
854
 
853
- // The violation list needs the same lazy Ruby-object conversion `ContainsView::from_core` does,
854
- // so this stays a free function rather than a method on either violation view class.
855
855
  fn object_violation_to_ruby(ruby: &Ruby, violation: &CoreObjectViolationView) -> Value {
856
856
  match violation {
857
857
  CoreObjectViolationView::NameFails(schema) => ruby
@@ -1133,7 +1133,7 @@ impl ObjectView {
1133
1133
  }
1134
1134
  }
1135
1135
 
1136
- /// A value matches iff at least one branch matches.
1136
+ /// Accepts a value any branch accepts.
1137
1137
  #[derive(magnus::TypedData)]
1138
1138
  #[magnus(class = "JSONSchema::Canonical::AnyOfView", free_immediately)]
1139
1139
  pub struct AnyOfView {
@@ -1174,7 +1174,7 @@ impl AnyOfView {
1174
1174
  }
1175
1175
  }
1176
1176
 
1177
- /// A value matches iff exactly one branch matches.
1177
+ /// Accepts a value exactly one branch accepts.
1178
1178
  #[derive(magnus::TypedData)]
1179
1179
  #[magnus(class = "JSONSchema::Canonical::OneOfView", free_immediately)]
1180
1180
  pub struct OneOfView {
@@ -1215,7 +1215,7 @@ impl OneOfView {
1215
1215
  }
1216
1216
  }
1217
1217
 
1218
- /// A value matches iff every branch matches.
1218
+ /// Accepts a value every branch accepts.
1219
1219
  #[derive(magnus::TypedData)]
1220
1220
  #[magnus(class = "JSONSchema::Canonical::AllOfView", free_immediately)]
1221
1221
  pub struct AllOfView {
@@ -1256,7 +1256,7 @@ impl AllOfView {
1256
1256
  }
1257
1257
  }
1258
1258
 
1259
- /// The negation of `schema`, preserving a symbolic ref under `not`, conditionals, and `oneOf`.
1259
+ /// Accepts the values `schema` rejects, keeping the references it names symbolic.
1260
1260
  #[derive(magnus::TypedData)]
1261
1261
  #[magnus(class = "JSONSchema::Canonical::NotView", free_immediately)]
1262
1262
  pub struct NotView {
@@ -1315,7 +1315,7 @@ impl ReferenceView {
1315
1315
  }
1316
1316
  }
1317
1317
 
1318
- /// Exactly one admitted value.
1318
+ /// Exactly one accepted value.
1319
1319
  #[derive(magnus::TypedData)]
1320
1320
  #[magnus(class = "JSONSchema::Canonical::ConstView", free_immediately)]
1321
1321
  pub struct ConstView {
@@ -1343,7 +1343,7 @@ impl ConstView {
1343
1343
  }
1344
1344
  }
1345
1345
 
1346
- /// A sorted, deduplicated finite set of admitted values.
1346
+ /// A sorted, deduplicated finite set of accepted values.
1347
1347
  #[derive(magnus::TypedData)]
1348
1348
  #[magnus(class = "JSONSchema::Canonical::EnumView", free_immediately)]
1349
1349
  pub struct EnumView {
@@ -1375,7 +1375,7 @@ impl EnumView {
1375
1375
  }
1376
1376
  }
1377
1377
 
1378
- /// One part of a schema object, as a reason names it.
1378
+ /// A schema location and the keywords there that a reason names.
1379
1379
  #[derive(magnus::TypedData)]
1380
1380
  #[magnus(class = "JSONSchema::Canonical::Cause", free_immediately)]
1381
1381
  pub struct Cause {
@@ -1438,8 +1438,7 @@ impl LiteralReason {
1438
1438
  }
1439
1439
  }
1440
1440
 
1441
- /// One part every value must satisfy admits nothing by itself. A subschema part has a reason of
1442
- /// its own under its pointer.
1441
+ /// One required part accepts no value; a subschema part is also reported under its own pointer.
1443
1442
  #[derive(magnus::TypedData)]
1444
1443
  #[magnus(class = "JSONSchema::Canonical::EmptyReason", free_immediately)]
1445
1444
  pub struct EmptyReason {
@@ -1467,7 +1466,7 @@ impl EmptyReason {
1467
1466
  }
1468
1467
  }
1469
1468
 
1470
- /// Each part admits values; no value satisfies all of them together.
1469
+ /// Each part accepts values; no value satisfies all of them together.
1471
1470
  #[derive(magnus::TypedData)]
1472
1471
  #[magnus(class = "JSONSchema::Canonical::ConflictReason", free_immediately)]
1473
1472
  pub struct ConflictReason {
@@ -1583,7 +1582,8 @@ fn with_canonical_options<R>(
1583
1582
  call(options.with_registry(registry.inner.as_ref()))
1584
1583
  }
1585
1584
 
1586
- /// The subschemas of `schema` that admit no value, by JSON Pointer, each with why.
1585
+ /// The subschemas of `schema` that accept no value, keyed by JSON Pointer, with the reason for
1586
+ /// each.
1587
1587
  fn find_unsatisfiable(ruby: &Ruby, args: &[Value]) -> Result<Value, Error> {
1588
1588
  let parsed = scan_args::<(Value,), (), (), (), _, ()>(args)?;
1589
1589
  let (schema_arg,) = parsed.required;
data/src/error_kind.rs CHANGED
@@ -164,7 +164,7 @@ impl ValidationErrorKind {
164
164
  ID_CONTENT_MEDIA_TYPE.to_symbol(),
165
165
  ruby.into_value(content_media_type.as_str()),
166
166
  )?,
167
- K::Custom { message, .. } | K::RegexEngineFailure { message } => rb_hash1(
167
+ K::Custom { message, .. } => rb_hash1(
168
168
  ruby,
169
169
  ID_MESSAGE.to_symbol(),
170
170
  ruby.into_value(message.as_str()),
@@ -188,9 +188,11 @@ impl ValidationErrorKind {
188
188
  ID_ERROR.to_symbol(),
189
189
  ruby.into_value(error.to_string().as_str()),
190
190
  )?,
191
- K::MaxItems { limit }
191
+ K::MaxContains { limit }
192
+ | K::MaxItems { limit }
192
193
  | K::MaxLength { limit }
193
194
  | K::MaxProperties { limit }
195
+ | K::MinContains { limit }
194
196
  | K::MinItems { limit }
195
197
  | K::MinLength { limit }
196
198
  | K::MinProperties { limit } => rb_hash1(