Skip to content

Multi-level validation transparency: surface schema and meta-schema issues in results #53

Description

@JulesGosnell

Summary

When validating a document (m1) against a schema (m2), M3 may trigger up to three levels of validation:

  • Level 0: m1 against m2 (document validation — what the user asked for)
  • Level 1: m2 against m3 (schema against its meta-schema, triggered by $schema)
  • Level 2: m3 against itself (meta-schema self-validation)

Currently, issues at levels 1 and 2 are either logged or silently swallowed. The caller only sees level 0 results. A malformed schema or broken meta-schema reference is invisible.

Problem

  • $ref resolution failures at level 1 are logged but don't surface (ref.cljc:117)
  • Meta-schema load failures are logged at INFO level (vocabulary.cljc:120)
  • URI loading exceptions are silently caught (validate.cljc:250)
  • Schema validation errors don't propagate down to the document validation result

Proposed output

{:valid? false
 :errors [{:schema-path [...] :message "type mismatch" ...}]
 :warnings [...]
 :schema-validation
   {:valid? true
    :warnings [{:message "format: not a valid uri" ...}]
    :meta-schema-validation
      {:valid? true}}}

Or flattened with level indicators:

{:valid? false
 :errors [...]
 :warnings [{:level :schema     :message "..." ...}
            {:level :meta-schema :message "..." ...}]}

Implementation notes

The M2/M1 flip means each level already runs through the same check-schemacompile-m2f1 pipeline. The challenge is threading results back down through the level transitions:

  • When level 1 (schema validation) completes, its errors/warnings need to be captured in c2
  • When level 0 returns its result, it attaches the level 1 results

This builds on #52 (warning system) — that issue adds the :warnings plumbing, this issue uses it across validation levels.

Depends on

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions