pub struct Config<'a> { /* private fields */ }
Expand description
A structure to hold configuration for a validation run.
Implementations§
Source§impl<'a> Config<'a>
impl<'a> Config<'a>
Sourcepub fn get_validator<'v>(
&self,
key: &'v str,
) -> Option<fn(cfg: &'v Config<'v>, instance: &'v Value, schema: &'v Value, parent_schema: Option<&'v Value>, ref_context: Context<'v>) -> ErrorIterator<'v>>
pub fn get_validator<'v>( &self, key: &'v str, ) -> Option<fn(cfg: &'v Config<'v>, instance: &'v Value, schema: &'v Value, parent_schema: Option<&'v Value>, ref_context: Context<'v>) -> ErrorIterator<'v>>
Get the validator object for the draft in use.
Sourcepub fn get_format_checker(
&self,
key: &str,
) -> Option<fn(cfg: &Config<'_>, value: &str) -> bool>
pub fn get_format_checker( &self, key: &str, ) -> Option<fn(cfg: &Config<'_>, value: &str) -> bool>
Get the string format checker for the draft in use.
Sourcepub fn get_draft_number(&self) -> u8
pub fn get_draft_number(&self) -> u8
Get the draft number in use.
Sourcepub fn get_metaschema(&self) -> &Value
pub fn get_metaschema(&self) -> &Value
Get the metaschema associated with the draft in use.
Sourcepub fn get_resolver(&self) -> &Resolver<'a>
pub fn get_resolver(&self) -> &Resolver<'a>
Get the resolver for the parsing context.
Sourcepub fn get_schema(&self) -> &Value
pub fn get_schema(&self) -> &Value
Get the schema currently being checked against.
Sourcepub fn from_schema(
schema: &'a Value,
draft: Option<Draft>,
) -> Result<Config<'a>, ValidationError>
pub fn from_schema( schema: &'a Value, draft: Option<Draft>, ) -> Result<Config<'a>, ValidationError>
Create a new Config object from a given schema.
Will use the Draft of JSON schema specified by draft
. If draft
is
None
, it will be automatically determined from the $schema
entry in
the given schema
. If no $schema
entry is present Draft 7 will be used
by default.
Sourcepub fn validate(&'a self, instance: &'a Value) -> Result<(), ErrorIterator<'a>>
pub fn validate(&'a self, instance: &'a Value) -> Result<(), ErrorIterator<'a>>
Validate the given JSON instance against the schema.
Sourcepub fn validate_schema(&'a self) -> Result<(), ErrorIterator<'a>>
pub fn validate_schema(&'a self) -> Result<(), ErrorIterator<'a>>
Validate the schema in this Config object against the metaschema.
Auto Trait Implementations§
impl<'a> Freeze for Config<'a>
impl<'a> RefUnwindSafe for Config<'a>
impl<'a> Send for Config<'a>
impl<'a> Sync for Config<'a>
impl<'a> Unpin for Config<'a>
impl<'a> UnwindSafe for Config<'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