pub struct ValueObjectFactory { /* private fields */ }Expand description
Factory for creating value objects from schema definitions and JSON values.
The factory maintains a registry of constructors and can dynamically create appropriate value objects based on attribute definitions.
Implementations§
Source§impl ValueObjectFactory
impl ValueObjectFactory
Sourcepub fn create_value_object(
&self,
definition: &AttributeDefinition,
value: &Value,
) -> ValidationResult<Box<dyn ValueObject>>
pub fn create_value_object( &self, definition: &AttributeDefinition, value: &Value, ) -> ValidationResult<Box<dyn ValueObject>>
Create a value object from a schema definition and JSON value.
Sourcepub fn get_expected_type(&self, attribute_name: &str) -> Option<AttributeType>
pub fn get_expected_type(&self, attribute_name: &str) -> Option<AttributeType>
Get the expected attribute type for a given attribute name.
Sourcepub fn register_constructor(
&mut self,
constructor: Box<dyn ValueObjectConstructor>,
)
pub fn register_constructor( &mut self, constructor: Box<dyn ValueObjectConstructor>, )
Register a custom constructor.
Sourcepub fn validate_composite_rules(
&self,
objects: &[Box<dyn ValueObject>],
) -> ValidationResult<()>
pub fn validate_composite_rules( &self, objects: &[Box<dyn ValueObject>], ) -> ValidationResult<()>
Validate composite rules across multiple value objects.
Sourcepub fn has_constructors(&self) -> bool
pub fn has_constructors(&self) -> bool
Check if the factory has any constructors registered.
Sourcepub fn create_value_objects_from_json(
&self,
definitions: &[AttributeDefinition],
json_obj: &Map<String, Value>,
) -> ValidationResult<Vec<Box<dyn ValueObject>>>
pub fn create_value_objects_from_json( &self, definitions: &[AttributeDefinition], json_obj: &Map<String, Value>, ) -> ValidationResult<Vec<Box<dyn ValueObject>>>
Create a collection of value objects from a JSON object.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValueObjectFactory
impl !RefUnwindSafe for ValueObjectFactory
impl !Send for ValueObjectFactory
impl !Sync for ValueObjectFactory
impl Unpin for ValueObjectFactory
impl !UnwindSafe for ValueObjectFactory
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
Source§impl<T> TenantValidator for T
impl<T> TenantValidator for T
Source§fn validate_tenant_context(
&self,
expected_tenant_id: &str,
context: &RequestContext,
) -> Result<(), String>
fn validate_tenant_context( &self, expected_tenant_id: &str, context: &RequestContext, ) -> Result<(), String>
Validate that the context has the expected tenant.
Source§fn validate_single_tenant_context(
&self,
context: &RequestContext,
) -> Result<(), String>
fn validate_single_tenant_context( &self, context: &RequestContext, ) -> Result<(), String>
Validate that the context is for single-tenant operation.
Source§fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
fn require_tenant_context(&self, context: &RequestContext) -> Result<(), String>
Extract tenant context or return error for multi-tenant operations.