1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
[](https://crates.io/crates/vld-data)
[](https://crates.io/crates/vld-data)
[](https://docs.rs/vld-data)
[](https://s00d.github.io/vld/integrations/database/sqlx)
[](https://github.com/s00d/vld/blob/main/LICENSE)
[](https://www.donationalerts.com/r/s00d88)
Validate values with [vld](https://crates.io/crates/vld) schemas before they are written to a database or a queue and after they are read back.
```toml
[dependencies]
vld = "0.8"
vld-data = { version = "0.8", features = ["sqlx-0_8", "sqlite"] }
```
```rust
use vld_data::sqlx08::prelude::*;
vld::schema! {
}
struct NewUser { name: String, email: String }
let user = NewUser { name: "Ada".into(), email: "not-an-email".into() };
assert!(validate_insert::<NewUserSchema, _>(&user).is_err()); // check before INSERT
```
No feature is on by default; any set can be enabled together.
- -
If vld helps you, you can support it via [DonationAlerts](https://www.donationalerts.com/r/s00d88).
Bugs and ideas: [issues](https://github.com/s00d/vld/issues).
MIT