pub struct Validator { /* private fields */ }Expand description
A compiled schema. Cheap to clone and safe to share between threads.
Implementations§
Source§impl Validator
impl Validator
Sourcepub fn is_valid(&self, instance: &Value) -> bool
pub fn is_valid(&self, instance: &Value) -> bool
Whether the instance is valid. A schema that recursed in place beyond the maximum depth is reported as
invalid; use Validator::validate to tell the two apart.
Sourcepub fn validate(
&self,
instance: &Value,
) -> Result<bool, SchemaEvaluationDepthError>
pub fn validate( &self, instance: &Value, ) -> Result<bool, SchemaEvaluationDepthError>
Whether the instance is valid, or an error if evaluation recursed in place beyond the maximum depth.
Sourcepub fn evaluate(
&self,
instance: &Value,
collector: &mut JsonSchemaResultsCollector,
) -> Result<bool, SchemaEvaluationDepthError>
pub fn evaluate( &self, instance: &Value, collector: &mut JsonSchemaResultsCollector, ) -> Result<bool, SchemaEvaluationDepthError>
Evaluates the instance exhaustively, reporting to the collector. Returns whether it is valid.
Sourcepub fn validate_instance<'a, I: Instance<'a>>(
&self,
instance: I,
) -> Result<bool, SchemaEvaluationDepthError>
pub fn validate_instance<'a, I: Instance<'a>>( &self, instance: I, ) -> Result<bool, SchemaEvaluationDepthError>
Validator::validate for any Instance: a value read in place, such as a host language’s own objects,
with no conversion to serde_json::Value.
Sourcepub fn validate_json(&self, json: &str) -> Result<bool, JsonValidationError>
pub fn validate_json(&self, json: &str) -> Result<bool, JsonValidationError>
Whether the JSON text is valid. The text is parsed into the thread’s reused buffers and evaluated in place: in
the steady state nothing is allocated. Use JsonDocument to validate the same text more than once.
Sourcepub fn evaluate_json(
&self,
json: &str,
collector: &mut JsonSchemaResultsCollector,
) -> Result<bool, JsonValidationError>
pub fn evaluate_json( &self, json: &str, collector: &mut JsonSchemaResultsCollector, ) -> Result<bool, JsonValidationError>
Validator::evaluate for JSON text, parsed as Validator::validate_json parses it.
Sourcepub fn evaluate_instance<'a, I: Instance<'a>>(
&self,
instance: I,
collector: &mut JsonSchemaResultsCollector,
) -> Result<bool, SchemaEvaluationDepthError>
pub fn evaluate_instance<'a, I: Instance<'a>>( &self, instance: I, collector: &mut JsonSchemaResultsCollector, ) -> Result<bool, SchemaEvaluationDepthError>
Validator::evaluate for any Instance.