# pystac.validation.stac_validator

exception pystac.validation.stac_validator.GetSchemaError(href: str, error: Exception)

  Raised when unable to fetch a schema.

class pystac.validation.stac_validator.JsonSchemaSTACValidator(schema_uri_map: SchemaUriMap | None = None)

  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]

    DEPRECATED

  property registry: Any
  schema_cache: dict[str, dict[str, Any]]
  schema_uri_map: SchemaUriMap
  validate_core(stac_dict: dict[str, Any], stac_object_type: STACObjectType, stac_version: str, href: str | None = None) → str | None

    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

    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

    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

    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`.

class pystac.validation.stac_validator.STACValidator

  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: STACObjectType, stac_version: str, extensions: list[str], href: str | None = None) → list[Any]

    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: STACObjectType, stac_version: str, href: str | None = None) → Any

    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: STACObjectType, stac_version: str, extension_id: str, href: str | None = None) → Any

    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.

previous

pystac.validation.schema_uri_map

next

pystac.version