pub struct InstanceValidator { /* private fields */ }Expand description
Validates JSON instances against JSON Structure schemas.
§Example
use json_structure::InstanceValidator;
use serde_json::json;
let validator = InstanceValidator::new();
let schema = json!({
"$id": "test",
"name": "Test",
"type": "string"
});
let result = validator.validate("\"hello\"", &schema);
assert!(result.is_valid());Implementations§
Source§impl InstanceValidator
impl InstanceValidator
Sourcepub fn with_options(options: InstanceValidatorOptions) -> Self
pub fn with_options(options: InstanceValidatorOptions) -> Self
Creates a new instance validator with the given options.
Sourcepub fn set_extended(&mut self, extended: bool)
pub fn set_extended(&mut self, extended: bool)
Enables or disables extended validation mode.
Sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Returns whether extended validation is enabled.
Sourcepub fn validate(&self, instance_json: &str, schema: &Value) -> ValidationResult
pub fn validate(&self, instance_json: &str, schema: &Value) -> ValidationResult
Validates a JSON instance against a schema.
Returns a ValidationResult that should be checked with is_valid().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InstanceValidator
impl RefUnwindSafe for InstanceValidator
impl Send for InstanceValidator
impl Sync for InstanceValidator
impl Unpin for InstanceValidator
impl UnwindSafe for InstanceValidator
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