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::sea2` — SeaORM 2 integration for `vld`
//!
//! Validate [`ActiveModel`](sea_orm::ActiveModelTrait) fields against a
//! [`vld`] schema **before** `insert()` / `update()` reaches the database:
//!
//! - [`validate_active`] — turns the `Set` / `Unchanged` values into a JSON
//! object (`NotSet` fields are omitted) and runs the schema;
//! - [`validate_model`] / [`validate_json`] — any `Serialize` value (an input
//! DTO, a `Model`) or raw JSON;
//! - [`before_save`] / [`impl_vld_before_save!`] — validation inside
//! [`ActiveModelBehavior::before_save`](sea_orm::ActiveModelBehavior::before_save).
//!
//! Feature `sea-orm-2`; SeaORM 2 is re-exported as [`sea_orm`].
//! `vld_data::sea1` is the same module for SeaORM 1 (feature
//! `sea-orm-1`); both can be enabled together. `with-json`,
//! `with-chrono`, `with-time`, `with-uuid`, `with-rust_decimal`,
//! `with-bigdecimal`, `postgres-array` map those column types to JSON
//! (without them such columns are validated as `null`).
//!
//! ```
//! use vld_data::sea2::prelude::*;
//! ```
//!
//! With an entity:
//!
//! ```rust,ignore
//! vld_data::sea2::validate_active::<UserInput, _>(&active_model)?;
//! // or, in the entity module, on every insert / update:
//! vld_data::sea2::impl_vld_before_save!(ActiveModel, super::UserInput);
//! ```
//!
//! Guide: <https://s00d.github.io/vld/integrations/database/sea-orm>
/// The SeaORM 2 crate this module is built on.
pub use sea_orm2 as sea_orm;
pub use vld;
// One implementation, compiled once per SeaORM major (ARCHITECTURE.md).
pub use *;
/// Implements [`ActiveModelBehavior`](sea_orm::ActiveModelBehavior) with
/// automatic vld validation in `before_save`.
///
/// ```rust,ignore
/// // In your entity module:
/// vld_data::sea2::impl_vld_before_save!(ActiveModel, UserInput);
/// // Different schemas for insert and update:
/// vld_data::sea2::impl_vld_before_save!(ActiveModel, insert: NewUser, update: UserPatch);
/// ```
///
/// This expands to an `ActiveModelBehavior` impl that calls
/// [`validate_active`] before every insert/update.
pub use crate__sea2_impl_vld_before_save as impl_vld_before_save;
/// SeaORM 2 glue.