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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! # vld-data — database and message-queue integrations for `vld`
//!
//! Validate values with `vld` schemas before they are written to a database
//! or a queue and after they are read back, one module per integration.
//! Every module except `surrealdb` is behind its feature; none is on by
//! default:
//!
//! ```toml
//! vld-data = { version = "0.8", features = ["sqlx-0_8", "postgres"] }
//! ```
//!
//! | Module | Feature | What it does |
//! |---|---|---|
//! | `sqlx08` / `sqlx09` | `sqlx-0_8` / `sqlx-0_9` + `postgres` / `mysql` / `sqlite` | validate before insert / after select, column wrappers implementing `sqlx::Type` |
//! | `diesel` | `diesel` + `postgres` / `mysql` / `sqlite` | the same for Diesel 2 (`AsExpression` / `FromSqlRow` column wrappers) |
//! | `sea1` / `sea2` | `sea-orm-1` / `sea-orm-2` + `with-*`, `postgres-array` | validate SeaORM `ActiveModel`s, `impl_vld_before_save!` |
//! | [`surrealdb`] | — (no dependency) | validate SurrealDB documents through `serde`, `validate_fields!` |
//! | `redis0` / `redis1` | `redis-0` / `redis-1` (+ `redis-aio`, `redis-aio-tokio`) | a validating JSON wrapper over a redis connection |
//! | `lapin2` / `lapin3` / `lapin4` | `lapin-2` / `lapin-3` / `lapin-4` | a validating JSON wrapper over a lapin (RabbitMQ) channel |
//!
//! The majors of one dependency are additive: any set of features compiles
//! together. The backend features `postgres` / `mysql` / `sqlite` apply to
//! every enabled sqlx / diesel driver; diesel's postgres and mysql backends
//! link libpq / libmysqlclient.
//!
//! ```rust
//! use vld_data::surrealdb::prelude::*;
//!
//! vld::schema! {
//! #[derive(Debug)]
//! pub struct NameField {
//! pub value: String => vld::string().min(1),
//! }
//! }
//!
//! assert!(VldText::<NameField>::new("Alice").is_ok());
//! assert!(VldText::<NameField>::new("").is_err());
//! ```
//!
//! Some features need a newer compiler than the crate's `rust-version`
//! (see MSRV.md); cargo reports the dependency's `rust-version` then.
pub use vld;