I don't have time to fully finish and maintain this library, and JSON schema validation in its current form is very limited and extremely inefficient.
I advise everyone not to use it if possible.
That being said, if anyone would like to continue it, I'll gladly grant maintainer access or even transfer ownership. I'm also open to giving up the name on crates.io if anyone wants it.
Verify is yet another validation library for Rust. Its main concept consists of validators that can validate values of any kind of structure. The idea is based on Serde's model, and there is even an optional wrapper for Serde-compatible types.
The library itself without features doesn't do much, it only provides trait definitions and common types.
In order to use it you need to write or find a validator, or enable one of the implementation features of the library. There is official support only for Schemars at the moment.
This very basic example shows how to create a self-validating type with Verify and Schemars:
(Schemars doesn't yet provide a way to add additional rules during derive, but will in the future.)
#[derive(Default, Verify, Serialize, JsonSchema)]
#[verify(schemars, serde)]
struct ExampleStruct {
example_value: i32,
}
fn main() {
let example = ExampleStruct::default();
// This will always return Ok(())
assert!(example.verify().is_ok());
}
There are quite a few things happening behind the scenes. For more details, visit the documentation.
For more examples visit the examples directory.
By default only the smallvec
feature is enabled.
Serde integration, it enables validating any value that implements Serialize.
Use smallvec for some types instead of Vec
in the library.
Enable Schemars integration by implementing Validator
, Verifier
and Verify
for its schema types.