Validation

ogcat.validate_metadata(metadata, schema, *, strict=False, schema_name='default')[source]

Validate metadata against a record schema.

Parameters:
  • metadata (object) – Metadata mapping to validate.

  • schema (RecordSchema) – Schema describing required fields and value types.

  • strict (bool) – Whether to apply strict schema options.

  • schema_name (str) – Human-readable schema name for messages.

Return type:

ValidationReport

Returns:

Structured validation report.

ogcat.validate_record(record, spec=None, *, strict=False)[source]

Validate a catalog record dataclass.

Parameters:
  • record (CatalogRecord) – Runtime catalog record to validate.

  • spec (CatalogSpec | None) – Optional catalog spec used for metadata schema validation.

  • strict (bool) – Whether to apply strict schema options.

Return type:

ValidationReport

Returns:

Structured validation report.

ogcat.validate_schema(schema, *, schema_name='default', base_path=None)[source]

Validate a record schema’s validation hints.

Parameters:
  • schema (RecordSchema) – Schema to validate.

  • schema_name (str) – Name used in issue paths and messages.

  • base_path (str | None) – Optional issue path prefix for the schema.

Return type:

ValidationReport

Returns:

Structured validation report.

ogcat.validate_spec(spec)[source]

Validate schema validation hints across a catalog spec.

Return type:

ValidationReport

class ogcat.ValidationReport(issues=<factory>)[source]

Bases: object

Structured validation result.

Parameters:

issues (list[ValidationIssue]) – Validation issues collected during a check.

issues: list[ValidationIssue]
property ok: bool

Return whether the report has no error issues.

property errors: list[ValidationIssue]

Return validation errors.

property warnings: list[ValidationIssue]

Return validation warnings.

add(*, path, message, severity='error', code='validation.error', hint=None)[source]

Add one issue to the report.

Return type:

None

extend(other)[source]

Add issues from another report.

Return type:

None

raise_for_errors()[source]

Raise a Python exception if the report contains errors.

Raises:
  • TypeError – If metadata itself is not a mapping.

  • ValueError – If one or more metadata values fail validation.

Return type:

None

class ogcat.ValidationIssue(path, message, severity='error', code='validation.error', hint=None)[source]

Bases: object

A single validation finding.

Parameters:
  • path (str) – Dot-separated path to the invalid value.

  • message (str) – Human-readable validation message.

  • severity (str) – Issue severity, usually "error" or "warning".

  • code (str) – Stable machine-readable issue code.

  • hint (str | None) – Optional user-facing remediation hint.

path: str
message: str
severity: str
code: str
hint: str | None