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
81
82
83
84
85
86
87
88
89
//! wellformed
//!
//! A portable FormSpec IR with Zod-like authoring for defining form schemas,
//! transforms, constraints, and error metadata.
//!
//! ## Overview
//!
//! wellformed provides a declarative, portable way to define form validation schemas
//! that can be:
//! - Serialized to JSON for cross-language interop
//! - Executed in the Rust runtime
//! - Used to generate code for other languages (TypeScript, OpenAPI, etc.)
//!
//! ## Key Features
//!
//! - **Type Layer**: Define structure with primitives, objects, arrays, enums
//! - **Transform Layer**: Normalize data before validation (trim, digits_only, etc.)
//! - **Constraint Layer**: Portable predicate AST for validation rules
//! - **Error Layer**: Structured, stable error codes with help text
//!
//! ## Optional Features
//!
//! - **`address`**: Enables address parsing predicates through the `postal`
//! crate. This feature requires the native libpostal C library, headers, and
//! parser data to be installed on the target system.
//!
//! ## Example
//!
//! ```rust
//! use wellformed::ir::*;
//! use wellformed::runtime::validate;
//! use serde_json::json;
//!
//! // Define a schema
//! let schema = Schema::new(
//! "1.0.0",
//! TypeSchema::Object(
//! ObjectSchema::new()
//! .property(
//! "tin",
//! TypeSchema::String(
//! StringSchema::new()
//! .transform(Transform::digits_only())
//! .constraint(Constraint::new(
//! Predicate::regex(r"^\d{9}$"),
//! ErrorMeta::new("TIN_INVALID", "TIN must be 9 digits"),
//! )),
//! ),
//! )
//! .property("name", TypeSchema::string()),
//! ),
//! );
//!
//! // Validate a value
//! let mut value = json!({
//! "tin": "123-45-6789",
//! "name": "Alice"
//! });
//!
//! let result = validate(&schema, &mut value).unwrap();
//! assert!(result.is_valid());
//! assert_eq!(value["tin"], json!("123456789")); // Transformed
//! ```
//!
//! See <https://wellformed.net/docs/rust-runtime> for Rust runtime usage.
// Re-export commonly used types at the crate root
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Address feature re-exports
pub use register_address_predicates;