pub struct MetaSchemaOptions<'a> { /* private fields */ }Expand description
Options for meta-schema validation.
Implementations§
Source§impl<'a> MetaSchemaOptions<'a>
impl<'a> MetaSchemaOptions<'a>
Sourcepub fn with_registry(self, registry: &'a Registry<'a>) -> Self
pub fn with_registry(self, registry: &'a Registry<'a>) -> Self
Use a registry for resolving custom meta-schemas.
§Examples
use serde_json::json;
use jsonschema::{Registry, Resource};
let custom_meta = Resource::from_contents(json!({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object"
}));
let registry = Registry::new()
.add("http://example.com/meta", custom_meta)
.unwrap()
.prepare()
.unwrap();
let options = jsonschema::meta::options()
.with_registry(®istry);Sourcepub fn is_valid(&self, schema: &Value) -> bool
pub fn is_valid(&self, schema: &Value) -> bool
Check if a schema is valid according to its meta-schema.
§Panics
Panics if the meta-schema cannot be resolved.
Sourcepub fn validate<'schema>(
&self,
schema: &'schema Value,
) -> Result<(), ValidationError<'schema>>
pub fn validate<'schema>( &self, schema: &'schema Value, ) -> Result<(), ValidationError<'schema>>
Validate a schema according to its meta-schema.
§Errors
Returns ValidationError if the schema is invalid or if the meta-schema cannot be resolved.
Trait Implementations§
Source§impl<'a> Clone for MetaSchemaOptions<'a>
impl<'a> Clone for MetaSchemaOptions<'a>
Source§fn clone(&self) -> MetaSchemaOptions<'a>
fn clone(&self) -> MetaSchemaOptions<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Default for MetaSchemaOptions<'a>
impl<'a> Default for MetaSchemaOptions<'a>
Source§fn default() -> MetaSchemaOptions<'a>
fn default() -> MetaSchemaOptions<'a>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for MetaSchemaOptions<'a>
impl<'a> !UnwindSafe for MetaSchemaOptions<'a>
impl<'a> Freeze for MetaSchemaOptions<'a>
impl<'a> Send for MetaSchemaOptions<'a>
impl<'a> Sync for MetaSchemaOptions<'a>
impl<'a> Unpin for MetaSchemaOptions<'a>
impl<'a> UnsafeUnpin for MetaSchemaOptions<'a>
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