pystac.validation#
- exception pystac.validation.GetSchemaError(href: str, error: Exception)[source]#
Raised when unable to fetch a schema.
- class pystac.validation.JsonSchemaSTACValidator(schema_uri_map: SchemaUriMap | None = None)[source]#
Validate STAC based on JSON Schemas.
This validator uses JSON schemas, read from URIs provided by a
SchemaUriMap
, to validate STAC core objects and extensions.- Parameters:
schema_uri_map – The SchemaUriMap that defines where the validator will retrieve the JSON schemas for validation. Defaults to an instance of
DefaultSchemaUriMap
Note: This class requires the
jsonschema
library to be installed.- validate_core(stac_dict: dict[str, Any], stac_object_type: STACObjectType, stac_version: str, href: str | None = None) str | None [source]#
Validate a core stac object.
Return value can be None or specific to the implementation.
- Parameters:
stac_dict – Dictionary that is the STAC json of the object.
stac_object_type – The stac object type of the object encoded in stac_dict. One of
STACObjectType
.stac_version – The version of STAC to validate the object against.
href – Optional HREF of the STAC object being validated.
- Returns:
- URI for the JSON schema that was validated against, or None if
no validation occurred.
- Return type:
- Raises:
STACValidationError if stac_dict is not valid. The exception is raised from – the “best” error, as determined by the jsonschema library. To access all jsonschema validation errors, use
STACValidationError.source
.
- validate_extension(stac_dict: dict[str, Any], stac_object_type: STACObjectType, stac_version: str, extension_id: str, href: str | None = None) str | None [source]#
Validate an extension stac object.
Return value can be None or specific to the implementation.
- Parameters:
stac_dict – Dictionary that is the STAC json of the object.
stac_object_type – The stac object type of the object encoded in stac_dict. One of
STACObjectType
.stac_version – The version of STAC to validate the object against.
extension_id – The extension ID to validate against.
href – Optional HREF of the STAC object being validated.
- Returns:
- URI for the JSON schema that was validated against, or None if
no validation occurred.
- Return type:
- Raises:
STACValidationError if stac_dict is not valid. The exception is raised from – the “best” error, as determined by the jsonschema library. To access all jsonschema validation errors, use
STACValidationError.source
.