pub struct FieldDefinition {
pub name: String,
pub field_type: String,
pub required: bool,
pub default: Option<Value>,
pub constraints: HashMap<String, Value>,
pub faker_template: Option<String>,
pub description: Option<String>,
}Expand description
Field definition for data generation
Fields§
§name: StringField name
field_type: StringField type
required: boolWhether the field is required
default: Option<Value>Default value (optional)
constraints: HashMap<String, Value>Additional constraints
faker_template: Option<String>Faker template (optional)
description: Option<String>Field description for RAG
Implementations§
Source§impl FieldDefinition
impl FieldDefinition
Sourcepub fn with_default(self, default: Value) -> Self
pub fn with_default(self, default: Value) -> Self
Set default value
Sourcepub fn with_constraint(self, key: String, value: Value) -> Self
pub fn with_constraint(self, key: String, value: Value) -> Self
Add a constraint
Sourcepub fn with_faker_template(self, template: String) -> Self
pub fn with_faker_template(self, template: String) -> Self
Set faker template
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Set description
Sourcepub fn generate_value(&self, faker: &mut EnhancedFaker) -> Value
pub fn generate_value(&self, faker: &mut EnhancedFaker) -> Value
Generate a value for this field
Sourcepub fn validate_value(&self, value: &Value) -> Result<()>
pub fn validate_value(&self, value: &Value) -> Result<()>
Validate a generated value against constraints
Trait Implementations§
Source§impl Clone for FieldDefinition
impl Clone for FieldDefinition
Source§fn clone(&self) -> FieldDefinition
fn clone(&self) -> FieldDefinition
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 FieldDefinition
impl Debug for FieldDefinition
Source§impl<'de> Deserialize<'de> for FieldDefinition
impl<'de> Deserialize<'de> for FieldDefinition
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
Auto Trait Implementations§
impl Freeze for FieldDefinition
impl RefUnwindSafe for FieldDefinition
impl Send for FieldDefinition
impl Sync for FieldDefinition
impl Unpin for FieldDefinition
impl UnwindSafe for FieldDefinition
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