Trait Keyword

Source
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§

Source

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.

Source

fn is_valid(&self, instance: &Value) -> bool

Validate instance and return a boolean result.

Could be potentilly faster than Keyword::validate method.

Implementors§