SchemaValidator

Struct SchemaValidator 

Source
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

Source

pub fn new(database_type: &str) -> Result<Self, SchemaError>

Create a new validator for a built-in database type

§Arguments
  • database_type - Name of a built-in database type (e.g., “threatdb”)
§Returns

A validator, or an error if the type is unknown

§Example
let validator = SchemaValidator::new("threatdb")?;
Source

pub fn schema_name(&self) -> &str

Get the schema name

Source

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)

Source

pub fn validate( &self, data: &HashMap<String, DataValue>, ) -> Result<(), SchemaValidationError>

Validate a yield value (HashMap of field name to DataValue)

§Arguments
  • data - The yield value to validate
§Returns

Ok(()) if valid, or SchemaValidationError with details

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

fn validate( &self, key: &str, data: &HashMap<String, DataValue>, ) -> Result<(), Box<dyn Error + Send + Sync>>

Validate entry data before insertion Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.