miranda.validate package

Data and schema validation module.

Submodules

miranda.validate._dimensions module

miranda.validate._regex module

Validation utilities and definitions.

miranda.validate._structure module

Data Validation module.

miranda.validate._variables module

miranda.validate.schema module

Validate outputted metadata against CF-like schemas.

miranda.validate.schema.validate_json(json_file: str | Path, schema: Schema | None = None) bool[source]

Validate a JSON file against a schema.

Parameters:
  • json_file (str or pathlib.Path) – The path to the JSON file.

  • schema (Schema, optional) – The schema to validate against. If None, will choose a definition based on filename parameters.

Returns:

bool – True if the JSON file is valid, False otherwise.

Raises:
  • ValueError – If the JSON file does not exist, or if the schema is not CF-compliant.

  • OSError – If there is an error reading the JSON file.

  • json.JSONDecodeError – If the JSON file is not valid JSON.

  • SchemaError – If the JSON data does not conform to the schema.

miranda.validate.url module

Validate URLs.

miranda.validate.url.url_validate(target: str) Match[str] | None[source]

Validate whether a supplied URL is reliably written.

Parameters:

target (str) – The URL to validate.

Returns:

typing.Match[str], optional – The match object if the URL is valid.

References

https://stackoverflow.com/a/7160778/7322852