pystac.validation.stac_validator#

class pystac.validation.stac_validator.JsonSchemaSTACValidator(schema_uri_map: Optional[pystac.validation.schema_uri_map.SchemaUriMap] = None)[source]#

Bases: pystac.validation.stac_validator.STACValidator

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.

get_schema_from_uri(schema_uri: str) Tuple[Dict[str, Any], Any][source]#
schema_cache: Dict[str, Dict[str, Any]]#
schema_uri_map: pystac.validation.schema_uri_map.SchemaUriMap#
validate_core(stac_dict: Dict[str, Any], stac_object_type: pystac.stac_object.STACObjectType, stac_version: str, href: Optional[str] = None) Optional[str][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

str

validate_extension(stac_dict: Dict[str, Any], stac_object_type: pystac.stac_object.STACObjectType, stac_version: str, extension_id: str, href: Optional[str] = None) Optional[str][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

str

class pystac.validation.stac_validator.STACValidator[source]#

Bases: abc.ABC

STACValidator defines methods for validating STAC JSON. Implementations define methods for validating core objects and extension. By default the JsonSchemaSTACValidator is used by PySTAC; users can define their own STACValidator implementation and set that validator to be used by pystac by using the set_validator() method.

validate(stac_dict: Dict[str, Any], stac_object_type: pystac.stac_object.STACObjectType, stac_version: str, extensions: List[str], href: Optional[str] = None) List[Any][source]#

Validate a STAC object JSON.

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.

  • extensions – Extension IDs for this stac object.

  • href – Optional href of the STAC object being validated.

Returns

List of return values from the validation calls for the

core object and any extensions. Element type is specific to the STACValidator implementation.

Return type

List[Any]

abstract validate_core(stac_dict: Dict[str, Any], stac_object_type: pystac.stac_object.STACObjectType, stac_version: str, href: Optional[str] = None) Any[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.

abstract validate_extension(stac_dict: Dict[str, Any], stac_object_type: pystac.stac_object.STACObjectType, stac_version: str, extension_id: str, href: Optional[str] = None) Any[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 of the extension to validate against.

  • href – Optional HREF of the STAC object being validated.