-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit af58a17
Showing
19 changed files
with
4,845 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"verify", | ||
"verify-macros" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Ferenc Tamás | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
- [Verify](#verify) | ||
- [Basic Usage](#basic-usage) | ||
- [Cargo Features](#cargo-features) | ||
- [serde](#serde) | ||
- [smallvec](#smallvec) | ||
- [schemars](#schemars) | ||
|
||
# Verify | ||
|
||
[](https://crates.io/crates/verify) | ||
[](https://docs.rs/verify) | ||
|
||
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](https://github.com/serde-rs/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 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](https://github.com/GREsau/schemars) at the moment. | ||
|
||
This very basic example shows how to create a self-validating type with Verify and Schemars: | ||
|
||
```rust | ||
|
||
#[derive(Default, Verify, Serialize, JsonSchema)] | ||
#[verify(schemars, serde)] | ||
struct ExampleStruct { | ||
example_value: i32, | ||
} | ||
|
||
fn main() { | ||
let example = ExampleStruct::default(); | ||
assert!(example.verify().is_ok()); | ||
} | ||
|
||
``` | ||
|
||
There are quite a few things happening behind the scenes. For more details, visit the [documentation](https://docs.rs/verify). | ||
|
||
## Cargo Features | ||
|
||
By default only the `smallvec` feature is enabled. | ||
|
||
### serde | ||
|
||
[Serde](https://github.com/serde-rs/serde) integration, it enables validating any value that implements [Serialize](https://docs.serde.rs/serde/trait.Serialize.html). | ||
|
||
### smallvec | ||
|
||
Use [smallvec](https://github.com/servo/rust-smallvec) for some types instead of `Vec` in the library. | ||
|
||
### schemars | ||
|
||
Enable [Schemars](https://github.com/GREsau/schemars) integration by implementing `Validator`, `Verifier` and `Verify` for its schema types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
authors = [ "tamasf97 <[email protected]>" ] | ||
description = "Procedural macros for the Verify library" | ||
edition = "2018" | ||
license = "MIT" | ||
name = "verify-macros" | ||
repository = "https://github.com/tamasfe/verify" | ||
version = "0.1.0" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
proc-macro-error = "1.0" | ||
proc-macro2 = "1.0" | ||
quote = "1.0" | ||
syn = "1.0" |
Oops, something went wrong.