jsonschema_rs 0.62.0 → 0.63.1

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: 80269187c4e9b0ad91da5f78b96da06d106644e83e2a551381ed3770deffc509
4
- data.tar.gz: cd9809d9012bfb27d46eb1dc5d0646552fde6c47d295eec7d89f26ba1d53d268
3
+ metadata.gz: 5e2cfb67c713f4219dc92d901268be8a1bf2ba2823a486057ee09601110adba1
4
+ data.tar.gz: 400e5cd0dcd73200a2aff56887698c2ee8460025c50f0621179b2997289dcdf9
5
5
  SHA512:
6
- metadata.gz: fe4ad2642951b8ab030fd359db326843e1ccf3afcb929cd582421428ce867539e38cb9d8ffab8053d38f939fb784e9dee1c62abc87efcaef6589d84ef74fd4da
7
- data.tar.gz: b4b75ab7a2c63575026b413fbda73fd653953dde5eb2c1aaf2ac776e231ddded9ce56673e015b8fe0e4b7eeb70a71ed69562bb32a5e2f4bd38d9a530bfdc018b
6
+ metadata.gz: 6cb373a9cdaa960f08a7c28b6a7764c1641d040abe38ea4aca68ccee12f35dceed92aeea6f4cbdbe77d7db69e5eed06622b5ec8cfea56c84b8f0ba7088d3ea4d
7
+ data.tar.gz: 459332dabaa8b9f4efc287de98ff0efb3ea89b3607cdc6b329602c0e769ce0b728bbe8b27fe3c53b4d21556b0909192b74344f5f9bcbd46dca1bf7a226997e78
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.62.0...HEAD
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/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "jsonschema-rb"
3
- version = "0.62.0"
3
+ version = "0.63.1"
4
4
  edition = "2021"
5
5
  authors = ["Dmitry Dygalo <dmitry@dygalo.dev>"]
6
6
  license = "MIT"
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
14
14
 
15
15
  [dependencies]
16
16
  strum = "0.28.0"
17
- jsonschema = { version = "0.62.0", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna"] }
17
+ jsonschema = { version = "0.63.1", default-features = false, features = ["magnus", "arbitrary-precision", "resolve-http", "resolve-file", "tls-ring", "macros", "idna", "json-text"] }
18
18
  magnus = { version = "0.9", features = ["rb-sys"] }
19
19
  rb-sys = "0.9"
20
20
  serde = { workspace = true }
data/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