pub struct ValidationService { /* private fields */ }Expand description
Schema validation service
Validates JSON data against schema definitions following a subset of JSON Schema specification. Designed for high-performance validation in streaming scenarios.
§Design Philosophy
- Zero allocation validation where possible
- Early exit on validation failures for performance
- Detailed error messages with full path context
- Composable validators for complex schemas
§Examples
let validator = ValidationService::new();
let schema = Schema::integer(Some(0), Some(100));
let data = JsonData::Integer(50);
assert!(validator.validate(&data, &schema, "/value").is_ok());Implementations§
Source§impl ValidationService
impl ValidationService
Sourcepub fn with_max_depth(max_depth: usize) -> Self
pub fn with_max_depth(max_depth: usize) -> Self
Create validation service with custom maximum depth
§Arguments
max_depth- Maximum nested validation depth
Sourcepub fn validate(
&self,
data: &JsonData,
schema: &Schema,
path: &str,
) -> SchemaValidationResult<()>
pub fn validate( &self, data: &JsonData, schema: &Schema, path: &str, ) -> SchemaValidationResult<()>
Validate JSON data against a schema
Performs comprehensive validation of JSON data against the provided schema, including type checking, constraint validation, and nested structure validation.
§Arguments
data- JSON data to validateschema- Schema to validate againstpath- Current JSON path for error reporting
§Returns
Ok(()) if validation succeeds, error with details if validation fails
§Errors
Returns SchemaValidationError with context when validation fails
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ValidationService
impl RefUnwindSafe for ValidationService
impl Send for ValidationService
impl Sync for ValidationService
impl Unpin for ValidationService
impl UnwindSafe for ValidationService
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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