Crate stac_validate

Source
Expand description

Validate STAC objects with json-schema.

§Examples

Validation is provided via the Validate trait:

use stac::Item;
use stac_validate::Validate;

Item::new("an-id").validate().await.unwrap();

If you’re working in a blocking context (not async), enable the blocking feature and use [ValidateBlocking]:

#[cfg(feature = "blocking")]
{
    use stac_validate::ValidateBlocking;
    Item::new("an-id").validate_blocking().unwrap();
}

All fetched schemas are cached, so if you’re you’re doing multiple validations, you should re-use the same Validator:

let mut items: Vec<_> = (0..10).map(|n| Item::new(format!("item-{}", n))).collect();
let mut validator = Validator::new().await;
for item in items {
    validator.validate(&item).await.unwrap();
}

Validator is cheap to clone, so you are encouraged to validate a large number of objects at the same time if that’s your use-case.

Structs§

Validator
A cloneable structure for validating STAC.

Enums§

Error
Crate-specific error type.

Traits§

Validate
Validate any serializable object with json-schema

Type Aliases§

Result
Crate-specific result type.