Skip to content

Extend stac-pydantic functionality #252

@jonhealy1

Description

@jonhealy1

Enable combined JSON Schema and Pydantic validation

Background

Currently, the STAC validator offers two separate validation approaches:

  1. Traditional JSON Schema validation (default)
  2. STAC-Pydantic model validation (via the --pydantic flag)

These approaches are implemented as mutually exclusive options in the codebase, where using --pydantic bypasses the default JSON Schema validation.

Problem

Users cannot benefit from both validation methods simultaneously. Each method has unique strengths:

  • JSON Schema validation thoroughly checks against the official STAC schemas
  • Pydantic validation provides enhanced type checking and more contextual error messages

By forcing users to choose one or the other, we're missing an opportunity to provide more comprehensive validation.

Proposed Solution

Modify the validator to allow both validation methods to run in sequence when desired:

  1. Add a new option like --validate-all or update the behavior of --pydantic to run both validations
  2. Aggregate and deduplicate validation results from both methods
  3. Present a unified validation report that clearly indicates which issues were found by which validator

Benefits

  • More thorough validation by leveraging the strengths of both approaches
  • Better error detection and reporting
  • Enhanced user confidence in validation results

Implementation Considerations

  • The default behavior should remain unchanged for backward compatibility
  • Performance impact of running both validations should be acceptable
  • The validation results format should clearly distinguish between issues found by each method
  • Consider how to handle conflicting validation results

Related Work

This enhancement builds on the Pydantic integration added in v3.7.0 and would make the validator more powerful by combining both validation approaches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions