pub struct DataValidator { /* private fields */ }Expand description
Validator for JSON data against Cedar type constraints.
Provides comprehensive validation including type checking, size limits, and format validation for extension types.
Implementations§
Source§impl DataValidator
impl DataValidator
Sourcepub fn with_config(config: ValidationConfig) -> Self
pub fn with_config(config: ValidationConfig) -> Self
Create a validator with custom configuration.
Sourcepub fn with_max_depth(self, max_depth: usize) -> Self
pub fn with_max_depth(self, max_depth: usize) -> Self
Set maximum nesting depth.
Sourcepub fn with_max_string_length(self, max_length: usize) -> Self
pub fn with_max_string_length(self, max_length: usize) -> Self
Set maximum string length.
Sourcepub fn with_max_array_length(self, max_length: usize) -> Self
pub fn with_max_array_length(self, max_length: usize) -> Self
Set maximum array length.
Sourcepub fn with_max_object_keys(self, max_keys: usize) -> Self
pub fn with_max_object_keys(self, max_keys: usize) -> Self
Set maximum object keys.
Sourcepub fn with_strict_extensions(self, strict: bool) -> Self
pub fn with_strict_extensions(self, strict: bool) -> Self
Enable strict extension format validation.
Sourcepub fn collect_all_errors(self, collect: bool) -> Self
pub fn collect_all_errors(self, collect: bool) -> Self
Enable collecting all errors instead of failing fast.
Sourcepub fn validate(&self, value: &Value) -> Result<(), ValidationError>
pub fn validate(&self, value: &Value) -> Result<(), ValidationError>
Validate a JSON value for Cedar compatibility.
If collect_all_errors is set in the config, this will collect all
errors before returning. Otherwise, it fails fast on the first error.
§Panics
This function will not panic. The expect call is guarded by a length check.
Sourcepub fn validate_detailed(&self, value: &Value) -> ValidationResult
pub fn validate_detailed(&self, value: &Value) -> ValidationResult
Validate a value and get a detailed result.
Sourcepub fn validate_type(
&self,
value: &Value,
expected: CedarType,
) -> Result<(), ValidationError>
pub fn validate_type( &self, value: &Value, expected: CedarType, ) -> Result<(), ValidationError>
Validate that a value matches an expected Cedar type.
Sourcepub fn validate_extension(
&self,
value: &str,
extension_type: &str,
) -> Result<(), ValidationError>
pub fn validate_extension( &self, value: &str, extension_type: &str, ) -> Result<(), ValidationError>
Validate an extension value format.
Supports all Cedar extension types:
ipaddr/ip: IP addresses and CIDR rangesdecimal: Fixed-precision decimal numbersdatetime: ISO 8601 / RFC 3339 timestampsduration: Duration strings (e.g., “2h30m”)
Trait Implementations§
Source§impl Clone for DataValidator
impl Clone for DataValidator
Source§fn clone(&self) -> DataValidator
fn clone(&self) -> DataValidator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DataValidator
impl Debug for DataValidator
Auto Trait Implementations§
impl Freeze for DataValidator
impl RefUnwindSafe for DataValidator
impl Send for DataValidator
impl Sync for DataValidator
impl Unpin for DataValidator
impl UnsafeUnpin for DataValidator
impl UnwindSafe for DataValidator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request