[][src]Crate verify


The main idea is based on Serde's Serialize and Serializer traits.

Similarly, Verify has a Validate trait that types can implement and decide how they should be validated, and a Validator trait for types that do the actual validation.

Spans contain information about each value during validation, with their help any deeply nested value can be identified after validation without additional lookups.

There are also two higher level traits: Verify and Verifier.

Verifiers validate values that implement Validate somehow internally, it might involve multiple validations and even validators or none at all.

Verify is implemented by types that can verify themselves somehow, it might or might not involve a Validator, nothing is known about the validation process apart from the output.

Note that validation and verification mean pretty much the same thing in the context of this library, the distinction is for naming purposes only.

Thanks to the similarity with Serde, validating serializable values is rather straightforward, read more about it here.

Basic Usage

The library itself without features doesn't do much, it only provides definitions and common traits.

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:

This code runs with edition 2018
#[derive(Default, Verify, Serialize, JsonSchema)]
#[verify(schemars, serde)]
struct ExampleStruct {
    example_value: i32,

let example = ExampleStruct::default();



Implementations for Schemars Schema types.


This module contains tools to make Serde Serializable values being able to be validated.


This module contains Span-related definitions and common Span types.



The errors returned by validators must implement this trait.


Convenience trait for interacting with errors.


Validate is implemented by values that can be validate themselves against a given validator.


Type returned by validate_map.


Type returned by validate_seq.


Values that implement Validate can validate themselves against types that implement this trait.


This trait is implemented by types that validate a value internally.


This trait is implemented by types that can validate themselves.

Derive Macros


Macro for deriving Verify.