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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
//! # Reinhardt Forms
//!
//! Form processing and validation for the Reinhardt framework.
//!
//! ## Overview
//!
//! This crate provides comprehensive form processing capabilities inspired by Django's
//! form system, focusing on data validation and multi-step form wizards.
//!
//! This crate is designed to be WASM-compatible, providing a pure form processing layer
//! without HTML generation or platform-specific features.
//!
//! ## Features
//!
//! - **[`Form`]**: Base form class with validation
//! - **[`ModelForm`]**: Auto-generated forms from model definitions
//! - **[`FormSet`]**: Handle multiple forms of the same type
//! - **[`FormWizard`]**: Multi-step form workflows
//! - **Field Types**: 20+ field types (CharField, IntegerField, EmailField, etc.)
//! - **WASM Support**: Compatible with WebAssembly targets via `wasm_compat` module
//!
//! ## Quick Start
//!
//! ### Basic Form
//!
//! ```rust,ignore
//! use reinhardt_forms::{Form, CharField, EmailField, IntegerField};
//!
//! // Build a form imperatively using add_field()
//! let mut form = Form::new();
//! form.add_field(Box::new(CharField::new("name")));
//! form.add_field(Box::new(EmailField::new("email")));
//! form.add_field(Box::new(IntegerField::new("age")));
//! form.add_field(Box::new(CharField::new("message")));
//!
//! // Validate form data
//! form.bind(&request_data);
//! if form.is_valid() {
//! // Process the validated form...
//! } else {
//! let errors = form.errors();
//! }
//! ```
//!
//! ### Prefixed Form Data
//!
//! A prefixed form expects submitted field names to use the prefix. The
//! validated values are exposed through canonical field names, while bound
//! fields continue to read the original submitted values for rerendering.
//!
//! ```rust
//! use reinhardt_forms::{CharField, Field, Form};
//! use serde_json::json;
//! use std::collections::HashMap;
//!
//! let mut form = Form::with_prefix("profile".to_string());
//! form.add_field(Box::new(CharField::new("name".to_string()).required()));
//! form.bind(HashMap::from([("profile-name".to_string(), json!("Ada"))]));
//!
//! assert!(form.is_valid());
//! assert_eq!(form.cleaned_data().get("name"), Some(&json!("Ada")));
//! assert_eq!(
//! form.get_bound_field("name").unwrap().value(),
//! Some(&json!("Ada"))
//! );
//! ```
//!
//! ### Model Form
//!
//! ```rust,ignore
//! use reinhardt_forms::{ModelForm, ModelFormBuilder};
//!
//! // Auto-generate form from User model
//! let form = ModelFormBuilder::<User>::new()
//! .fields(vec!["username".to_string(), "email".to_string(), "bio".to_string()])
//! .exclude(vec!["password".to_string()])
//! .build();
//! ```
//!
//! ## Available Field Types
//!
//! | Field | Description |
//! |-------|-------------|
//! | [`CharField`] | Text input with max_length validation |
//! | [`IntegerField`] | Integer input with min/max validation |
//! | [`FloatField`] | Floating-point number input |
//! | [`DecimalField`] | Decimal number with precision control |
//! | [`BooleanField`] | Checkbox input |
//! | [`EmailField`] | Email address validation |
//! | [`URLField`] | URL validation |
//! | [`DateField`] | Date input with format parsing |
//! | [`DateTimeField`] | DateTime input |
//! | [`TimeField`] | Time input |
//! | [`DurationField`] | Duration input |
//! | [`FileField`] | File upload |
//! | [`ImageField`] | Image upload with dimension validation |
//! | [`ChoiceField`] | Select dropdown |
//! | [`MultipleChoiceField`] | Multi-select |
//! | [`ModelChoiceField`] | Foreign key selection |
//! | [`ModelMultipleChoiceField`] | Multiple model selection with normalized dirty-state comparison |
//! | [`JSONField`] | JSON data input |
//! | [`UUIDField`] | UUID input |
//! | [`SlugField`] | URL-safe slug input |
//! | [`RegexField`] | Custom regex validation |
//!
//! `ModelMultipleChoiceField` compares selected values without considering
//! order when [`Form::has_changed`] runs. Numeric IDs and strings with the same
//! textual representation are equivalent, while booleans, nulls, arrays, and
//! objects remain distinct JSON types.
//!
//! ## FormSets
//!
//! Handle multiple forms of the same type:
//!
//! ```rust,ignore
//! use reinhardt_forms::{FormSet, FormSetFactory};
//!
//! // Create a formset with 3 forms
//! let formset = FormSetFactory::<ItemForm>::new()
//! .extra(3)
//! .min_num(1)
//! .max_num(10)
//! .build();
//!
//! if formset.is_valid() {
//! for form in formset.forms() {
//! // Process each form
//! }
//! }
//! ```
//!
//! ## Form Wizard
//!
//! Multi-step forms:
//!
//! ```rust,ignore
//! use reinhardt_forms::{FormWizard, WizardStep};
//!
//! let wizard = FormWizard::new()
//! .add_step(WizardStep::new("account", AccountForm::new()))
//! .add_step(WizardStep::new("profile", ProfileForm::new()))
//! .add_step(WizardStep::new("confirmation", ConfirmForm::new()));
//!
//! // Process wizard step
//! let result = wizard.process_step(&request).await?;
//! ```
/// Bound field rendering with data and errors attached.
/// Core form field trait and error types.
/// Built-in field types (text, email, integer, choice, etc.).
/// Form trait and validation logic.
/// Formset for managing multiple form instances.
/// Built-in formset types (inline, base).
/// Model-backed form with automatic field generation.
/// Model-backed formset for bulk editing.
/// Field-level and form-level validators.
/// WASM compatibility layer for client-side forms.
/// Multi-step form wizard.
pub use BoundField;
pub use ;
pub use ;
pub use ;
pub use FormSet;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;