Skip to content

Validate

stacrs.validate builtin

validate(value: dict[str, Any]) -> None

Validates a STAC dictionary with json-schema.

Parameters:

Name Type Description Default
value dict[str, Any]

The STAC value to validate

required

Raises:

Type Description
Exception

On a validation error

Examples:

>>> with open("examples/simple-item.json") as f:
>>>     data = json.load(f)
>>> stacrs.validate(data)

stacrs.validate_href builtin

validate_href(href: str) -> None

Validates a single href with json-schema.

Parameters:

Name Type Description Default
href str

The href of the STAC value to validate

required

Raises:

Type Description
Exception

On any input/output error, or on a validation error

Examples:

>>> stacrs.validate_href("examples/simple-item.json")
>>> stacrs.validate_href("data/invalid-item.json")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: Validation errors: "collection" is a required property