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 +4 -4
- data/CHANGELOG.md +28 -1
- data/Cargo.toml +2 -2
- data/README.md +30 -0
- data/ext/jsonschema/Cargo.lock +324 -354
- data/ext/jsonschema/Cargo.toml +3 -3
- data/lib/jsonschema/version.rb +1 -1
- data/sig/jsonschema.rbs +54 -7
- data/src/json_text.rs +239 -0
- data/src/lib.rs +102 -35
- data/src/options.rs +177 -34
- data/src/ser.rs +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5e2cfb67c713f4219dc92d901268be8a1bf2ba2823a486057ee09601110adba1
|
|
4
|
+
data.tar.gz: 400e5cd0dcd73200a2aff56887698c2ee8460025c50f0621179b2997289dcdf9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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.
|
|
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.
|
|
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
|