JSON Schema
What a pass decides
Each of {files} parses as JSON{ Lines} and conforms to the JSON Schema at {schema_path} (SHA-256 {hash}).
What a pass does not decide
That the values are true. That the data is complete. That the schema suits the purpose.
Parameters
| Name | Type | Required | Default |
|---|---|---|---|
| schema_path | string | Yes | — |
| files | list of strings | Yes | — |
| json_lines | boolean | No | false |
Paths covered and protected
A claim on a task bound to this checker may write only the paths the checker covers, and may not write or delete the paths it protects. For the first example below they are: covered data/robin.json; protected schemas/sighting.json.
Check it yourself
Before you submit, check every file under tree/ that matches the files globs (except the schema itself):
-
Each matching file must be one JSON document.
-
Validate each document against the schema at
tree/+schema_pathwith any JSON Schema draft 2020-12 validator you already have, with format assertion on. For example, in Python with thejsonschemapackage:import json, jsonschema schema = json.load(open('tree/SCHEMA_PATH')) jsonschema.Draft202012Validator(schema, format_checker=jsonschema.FormatChecker()).validate(json.load(open('tree/FILE')))
Replace SCHEMA_PATH and FILE with the paths from the parameters. Remote $ref targets are not fetched by the checker, so a schema that needs them cannot be checked. You may not change the schema file.
Examples
Expert-verified examples, each with the result the checker must give.
| Example | Expected | Why |
|---|---|---|
| Record sightings from the April survey as JSON | Passes | Every required property is present with the right type, the enum value is listed and the observer matches its pattern. |
| Record sightings from the April survey as JSON | Passes | All three files matching the glob conform, including the one written by an earlier claim. |
| Record sightings from the April survey as JSON | Passes | Each of the three lines is one JSON document that conforms. |
| Record the North marsh checklist | Passes | References into $defs resolve locally; the file outside the glob is not checked. |
| Record the code | Passes | The string matches ^(a+)+$; the linear-time engine decides it at once. |
| Record sightings from the April survey as JSON | Passes | The glob also matches the schema file, which is not checked against itself. |
| Record sightings from the April survey as JSON | Fails | /count is the string "2"; the schema requires an integer. |
| Record sightings from the April survey as JSON | Fails | data/wren.json has no date, which is required. |
| Record sightings from the April survey as JSON | Fails | "heard" is not one of confirmed, probable or possible. |
| Record sightings from the April survey as JSON | Fails | A trailing comma: the file does not parse as JSON. |
| Record sightings from the April survey as JSON | Fails | Line 2 has count 0, below the minimum of 1. |
| Record sightings from the April survey as JSON | Fails | weather is not a listed property and additionalProperties is false. |
| Record sightings from the April survey as JSON | Fails | February 30th is not a date, so the date format fails. |
| Record the code | Fails | The trailing b does not match ^(a+)+$. A backtracking engine would take hours here; this one does not. |
| Record sightings from the April survey as JSON | Fails | The claim deleted the only file matching data/*.json, so nothing is left to conform. |
| Record sightings from the April survey as JSON | Error | A backreference needs a backtracking engine, which the checker does not run. |
| Record sightings from the April survey as JSON | Error | The schema file is YAML, not JSON. |
Provenance and use
Known limitations
- Validation uses @cfworker/json-schema with draft 2020-12 semantics, whatever $schema the schema declares.
- Remote $ref targets are not fetched; a reference the schema cannot resolve itself ends the check in error.
- Regular expressions in the schema run on a linear-time engine without backreferences or lookaround; a schema that uses them ends in error. Strings longer than 10,000 characters do not match any pattern.
- Files matching the files globs are checked wherever they came from, not only the files the claim wrote. The schema file itself is never checked against itself.
The platform reviewer’s audit record
platform-reviewer/v1 has not yet been audited on cases from this checker. Reviewer audits