verify

Crates.ioverify
lib.rsverify
version0.3.2
sourcesrc
created_at2020-06-11 01:25:46.704952
updated_at2020-06-21 22:49:18.801832
descriptionA validation library
homepage
repositoryhttps://github.com/tamasfe/verify
max_upload_size
id252571
size139,600
Ferenc Tamás (tamasfe)

documentation

README

Verify

Latest Version Documentation

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.

Basic Usage

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.

Cargo Features

By default only the smallvec feature is enabled.

serde

Serde integration, it enables validating any value that implements Serialize.

smallvec

Use smallvec for some types instead of Vec in the library.

schemars

Enable Schemars integration by implementing Validator, Verifier and Verify for its schema types.

Commit count: 14

cargo fmt