pub struct FormBuilder {
pub id: String,
pub name: String,
pub version: u32,
pub fields: Vec<FieldDefinition>,
}Expand description
Builder for constructing validated FormDefinition instances.
Fields§
§id: StringThe unique identifier for this form.
name: StringHuman-readable name for the form.
version: u32The version number for the form. Defaults to 1.
fields: Vec<FieldDefinition>The list of field definitions that make up this form.
Implementations§
Source§impl FormBuilder
impl FormBuilder
Sourcepub fn new(id: &str, name: &str) -> Self
pub fn new(id: &str, name: &str) -> Self
Creates a new FormBuilder instance with the given ID and name,
defaulting the version to 1 and fields to an empty list.
Sourcepub fn add_field(self, field: FieldDefinition) -> Self
pub fn add_field(self, field: FieldDefinition) -> Self
Adds a FieldDefinition to the form.
Sourcepub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
pub fn with_fields(self, fields: Vec<FieldDefinition>) -> Self
Replaces the current list of fields with a new vector of FieldDefinitions.
Sourcepub fn build(self) -> Result<FormDefinition, ValidationErrors>
pub fn build(self) -> Result<FormDefinition, ValidationErrors>
Builds a validated FormDefinition from the FormBuilder instance.
§Returns
A Result containing the FormDefinition if valid, or a
validator::ValidationErrors if validation fails.
Trait Implementations§
Source§impl Clone for FormBuilder
impl Clone for FormBuilder
Source§fn clone(&self) -> FormBuilder
fn clone(&self) -> FormBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FormBuilder
impl Debug for FormBuilder
Source§impl<'de> Deserialize<'de> for FormBuilder
impl<'de> Deserialize<'de> for FormBuilder
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for FormBuilder
impl Serialize for FormBuilder
Source§impl TryFrom<FormBuilder> for FormDefinition
impl TryFrom<FormBuilder> for FormDefinition
Source§type Error = ValidationErrors
type Error = ValidationErrors
The type returned in the event of a conversion error.
Auto Trait Implementations§
impl Freeze for FormBuilder
impl RefUnwindSafe for FormBuilder
impl Send for FormBuilder
impl Sync for FormBuilder
impl Unpin for FormBuilder
impl UnwindSafe for FormBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more