pub trait Keyword: Send + Sync {
// Required methods
fn validate<'i>(
&self,
instance: &'i Value,
location: &LazyLocation<'_, '_>,
) -> Result<(), ValidationError<'i>>;
fn is_valid(&self, instance: &Value) -> bool;
}Expand description
Trait that allows implementing custom validation for keywords.
Required Methods§
Sourcefn validate<'i>(
&self,
instance: &'i Value,
location: &LazyLocation<'_, '_>,
) -> Result<(), ValidationError<'i>>
fn validate<'i>( &self, instance: &'i Value, location: &LazyLocation<'_, '_>, ) -> Result<(), ValidationError<'i>>
Validate instance according to a custom specification.
A custom keyword validator may be used when a validation that cannot be easily or efficiently expressed in JSON schema.
The custom validation is applied in addition to the JSON schema validation.
Sourcefn is_valid(&self, instance: &Value) -> bool
fn is_valid(&self, instance: &Value) -> bool
Validate instance and return a boolean result.
Could be potentilly faster than Keyword::validate method.