pub struct SchemaValidator { /* private fields */ }Expand description
Schema validator with caching for performance
Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn with_limits(max_payload_size: usize, max_schemas: usize) -> Self
pub fn with_limits(max_payload_size: usize, max_schemas: usize) -> Self
Create a validator with custom limits
Sourcepub fn register(&mut self, stype: &str, schema: Value) -> Result<()>
pub fn register(&mut self, stype: &str, schema: Value) -> Result<()>
Register a schema for an SType
Sourcepub fn schema_count(&self) -> usize
pub fn schema_count(&self) -> usize
Get current number of registered schemas
Sourcepub fn max_payload_size(&self) -> usize
pub fn max_payload_size(&self) -> usize
Get maximum payload size limit
Sourcepub fn register_json(&mut self, stype: &str, schema_json: &str) -> Result<()>
pub fn register_json(&mut self, stype: &str, schema_json: &str) -> Result<()>
Register a schema from a JSON string
Sourcepub fn has_schema(&self, stype: &str) -> bool
pub fn has_schema(&self, stype: &str) -> bool
Check if a schema is registered
Sourcepub fn validate(&self, stype: &str, payload: &Value) -> Result<ValidationResult>
pub fn validate(&self, stype: &str, payload: &Value) -> Result<ValidationResult>
Validate a payload against its declared SType
Sourcepub fn validate_qom(&self, stype: &str, payload: &Value) -> Result<QomMetrics>
pub fn validate_qom(&self, stype: &str, payload: &Value) -> Result<QomMetrics>
Validate and return QoM metrics
Sourcepub fn validate_or_error(&self, stype: &str, payload: &Value) -> Result<()>
pub fn validate_or_error(&self, stype: &str, payload: &Value) -> Result<()>
Validate and return an MplError if invalid
Sourcepub fn registered_stypes(&self) -> Vec<&str>
pub fn registered_stypes(&self) -> Vec<&str>
Get all registered STypes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaValidator
impl !RefUnwindSafe for SchemaValidator
impl Send for SchemaValidator
impl Sync for SchemaValidator
impl Unpin for SchemaValidator
impl !UnwindSafe for SchemaValidator
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointerSource§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