pub struct SchemaValidator { /* private fields */ }Expand description
Validates JSON Structure schema documents.
§Example
use json_structure::SchemaValidator;
let validator = SchemaValidator::new();
let result = validator.validate(r#"{"$id": "test", "name": "Test", "type": "string"}"#);
assert!(result.is_valid());Implementations§
Source§impl SchemaValidator
impl SchemaValidator
Sourcepub fn with_options(options: SchemaValidatorOptions) -> Self
pub fn with_options(options: SchemaValidatorOptions) -> Self
Creates a new schema 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. Note: Schema validation always validates extended keywords; this is a placeholder for API consistency.
Sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Returns whether extended validation is enabled. Note: Schema validation always validates extended keywords.
Sourcepub fn set_warn_on_extension_keywords(&mut self, warn: bool)
pub fn set_warn_on_extension_keywords(&mut self, warn: bool)
Enables or disables warnings for extension keywords without $uses.
Sourcepub fn is_warn_on_extension_keywords(&self) -> bool
pub fn is_warn_on_extension_keywords(&self) -> bool
Returns whether warnings are enabled for extension keywords.
Sourcepub fn validate(&self, schema_json: &str) -> ValidationResult
pub fn validate(&self, schema_json: &str) -> ValidationResult
Validates a JSON Structure schema from a string.
Returns a ValidationResult that should be checked with is_valid().
Sourcepub fn validate_value(
&self,
schema: &Value,
schema_json: &str,
) -> ValidationResult
pub fn validate_value( &self, schema: &Value, schema_json: &str, ) -> ValidationResult
Validates a JSON Structure schema from a parsed Value.
Returns a ValidationResult that should be checked with is_valid().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaValidator
impl RefUnwindSafe for SchemaValidator
impl Send for SchemaValidator
impl Sync for SchemaValidator
impl Unpin for SchemaValidator
impl UnwindSafe for SchemaValidator
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