Skip to main content

siderite_validation/
lib.rs

1//! Pydantic v2-inspired validation, serialization options and JSON Schema
2//! metadata for siderite.
3//!
4//! - [`Validate`]: type-driven `prepare` (coercion and checks on raw input,
5//!   every error collected) plus `validate` (constraints and validators on the
6//!   typed value).
7//! - [`parse_value`] / [`parse_json`]: the full pipeline, like `model_validate`.
8//! - [`ValidationContext`] / [`ModelConfig`]: locations, strictness, string
9//!   transforms, extra-key policy and user data.
10//! - [`ModelHooks`]: field/model validators, computed fields, serializers.
11//! - [`Dump`] / [`DumpOptions`]: `model_dump`-style output options.
12//! - [`Schema`]: JSON Schema / OpenAPI 3.1 metadata.
13//! - [`Change`]: a partial-update field, absent or set (`null` included).
14//! - [`rules`] and constrained [`types`].
15#![forbid(unsafe_code)]
16
17pub mod change;
18pub mod context;
19pub mod dump;
20pub mod error;
21pub mod hooks;
22pub mod model;
23pub mod pipeline;
24pub mod rules;
25pub mod schema;
26pub mod types;
27pub mod validate;
28
29pub use change::Change;
30pub use context::{Extra, InputKind, ModelConfig, ValidationContext};
31pub use dump::{Dump, DumpError, DumpOptions, FieldSet};
32pub use error::{FieldError, LocationItem, ValidationError, ValidationResult};
33pub use hooks::ModelHooks;
34pub use pipeline::{parse_json, parse_value, text_pairs_to_value, validate};
35pub use rules::{
36    decimal_digits, email, ge, gt, ip, le, lt, max_length, min_length, multiple_of, pattern, url,
37    uuid,
38};
39pub use schema::{Schema, SchemaConflict, SchemaObject, SchemaRegistry, schema_for};
40pub use types::{
41    BoundedFloat, BoundedI64, ConstrainedString, ConstrainedVec, Decimal, Email, FloatBounds,
42    HttpUrl, IpAddress, Ipv4Address, Ipv6Address, NegativeInt, NonNegative, NonNegativeInt,
43    Positive, PositiveInt, SecretString, UnboundedDecimal, UnitInterval, Url, Uuid,
44};
45pub use validate::Validate;