pub struct CustomSchema {
pub name: String,
pub allowed_types: Vec<ScalarType>,
pub custom_validators: HashMap<ScalarType, Box<dyn Fn(&str, &str) -> CustomValidationResult + Send + Sync>>,
pub allow_coercion: bool,
}Expand description
Custom schema definition with user-defined validation rules
Fields§
§name: StringSchema name for error messages
allowed_types: Vec<ScalarType>Allowed scalar types in this schema
custom_validators: HashMap<ScalarType, Box<dyn Fn(&str, &str) -> CustomValidationResult + Send + Sync>>Custom validation functions by type
allow_coercion: boolWhether to allow type coercion
Implementations§
Source§impl CustomSchema
impl CustomSchema
Sourcepub fn allow_type(self, scalar_type: ScalarType) -> Self
pub fn allow_type(self, scalar_type: ScalarType) -> Self
Allow a specific scalar type
Sourcepub fn allow_types(self, types: &[ScalarType]) -> Self
pub fn allow_types(self, types: &[ScalarType]) -> Self
Allow multiple scalar types
Sourcepub fn with_validator<F>(self, scalar_type: ScalarType, validator: F) -> Self
pub fn with_validator<F>(self, scalar_type: ScalarType, validator: F) -> Self
Add a custom validator for a specific type
Sourcepub fn allows_type(&self, scalar_type: ScalarType) -> bool
pub fn allows_type(&self, scalar_type: ScalarType) -> bool
Check if a scalar type is allowed
Sourcepub fn validate_scalar(
&self,
content: &str,
path: &str,
) -> Result<(), ValidationError>
pub fn validate_scalar( &self, content: &str, path: &str, ) -> Result<(), ValidationError>
Validate a scalar value with custom rules
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CustomSchema
impl !RefUnwindSafe for CustomSchema
impl Send for CustomSchema
impl Sync for CustomSchema
impl Unpin for CustomSchema
impl UnsafeUnpin for CustomSchema
impl !UnwindSafe for CustomSchema
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