pub struct SchemaValidator { /* private fields */ }Expand description
Validates yield values against a built-in schema
Currently supports the ThreatDB schema for threat intelligence databases. Validation is performed directly in Rust for speed and simplicity.
Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn new(database_type: &str) -> Result<Self, SchemaError>
pub fn new(database_type: &str) -> Result<Self, SchemaError>
Sourcepub fn schema_name(&self) -> &str
pub fn schema_name(&self) -> &str
Get the schema name
Sourcepub fn database_type(&self) -> Option<&'static str>
pub fn database_type(&self) -> Option<&'static str>
Get the canonical database_type that should be set in metadata
Returns None if this validator was created from custom JSON (not a built-in type)
Sourcepub fn validate(
&self,
data: &HashMap<String, DataValue>,
) -> Result<(), SchemaValidationError>
pub fn validate( &self, data: &HashMap<String, DataValue>, ) -> Result<(), SchemaValidationError>
Sourcepub fn validate_detailed(
&self,
data: &HashMap<String, DataValue>,
) -> Vec<ValidationErrorDetail>
pub fn validate_detailed( &self, data: &HashMap<String, DataValue>, ) -> Vec<ValidationErrorDetail>
Validate and return a detailed result (useful for collecting all errors)
Trait Implementations§
Source§impl Debug for SchemaValidator
impl Debug for SchemaValidator
Source§impl EntryValidator for SchemaValidator
Implement EntryValidator trait for SchemaValidator
impl EntryValidator for SchemaValidator
Implement EntryValidator trait for SchemaValidator
This allows SchemaValidator to be used with DatabaseBuilder::with_validator() for automatic schema validation during database construction.
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more