https://github.com/santhosh-tekuri/jsonschema
JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation using Go
https://github.com/santhosh-tekuri/jsonschema
draft2019-09 draft2020-12 draft4 draft6 draft7 go golang golang-library json json-schema jsonschema validation validator
Last synced: 2 days ago
JSON representation
JSONSchema (draft 2020-12, draft 2019-09, draft-7, draft-6, draft-4) Validation using Go
- Host: GitHub
- URL: https://github.com/santhosh-tekuri/jsonschema
- Owner: santhosh-tekuri
- License: apache-2.0
- Created: 2017-05-09T22:41:26.000Z (about 8 years ago)
- Default Branch: boon
- Last Pushed: 2025-04-11T16:10:38.000Z (about 1 month ago)
- Last Synced: 2025-04-11T17:26:20.116Z (about 1 month ago)
- Topics: draft2019-09, draft2020-12, draft4, draft6, draft7, go, golang, golang-library, json, json-schema, jsonschema, validation, validator
- Language: Go
- Homepage:
- Size: 814 KB
- Stars: 1,040
- Watchers: 7
- Forks: 107
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - jsonschema - 12, draft 2019-09, draft-7, draft-6, draft-4) Validation using Go (Repositories)
README
# jsonschema v6.0.1
[](https://opensource.org/licenses/Apache-2.0)
[](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6)
[](https://goreportcard.com/report/github.com/santhosh-tekuri/jsonschema/v6)
[](https://github.com/santhosh-tekuri/jsonschema/actions/workflows/go.yaml)
[](https://codecov.io/gh/santhosh-tekuri/jsonschema/tree/boon)see [godoc](https://pkg.go.dev/github.com/santhosh-tekuri/jsonschema/v6) for examples
## Library Features
- [x] pass [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) excluding optional(compare with other impls at [bowtie](https://bowtie-json-schema.github.io/bowtie/#))
- [x] [](https://bowtie.report/#/dialects/draft4)
- [x] [](https://bowtie.report/#/dialects/draft6)
- [x] [](https://bowtie.report/#/dialects/draft7)
- [x] [](https://bowtie.report/#/dialects/draft2019-09)
- [x] [](https://bowtie.report/#/dialects/draft2020-12)
- [x] detect infinite loop traps
- [x] `$schema` cycle
- [x] validation cycle
- [x] custom `$schema` url
- [x] vocabulary based validation
- [x] custom regex engine
- [x] format assertions
- [x] flag to enable in draft >= 2019-09
- [x] custom format registration
- [x] built-in formats
- [x] regex, uuid
- [x] ipv4, ipv6
- [x] hostname, email
- [x] date, time, date-time, duration
- [x] json-pointer, relative-json-pointer
- [x] uri, uri-reference, uri-template
- [x] iri, iri-reference
- [x] period, semver
- [x] content assertions
- [x] flag to enable in draft >= 7
- [x] contentEncoding
- [x] base64
- [x] custom
- [x] contentMediaType
- [x] application/json
- [x] custom
- [x] contentSchema
- [x] errors
- [x] introspectable
- [x] hierarchy
- [x] alternative display with `#`
- [x] output
- [x] flag
- [x] basic
- [x] detailed
- [x] custom vocabulary
- enable via `$vocabulary` for draft >=2019-19
- enable via flag for draft <= 7
- [x] mixed dialect support## CLI v0.7.0
to install: `go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest`
Note that the cli is versioned independently. you can see it in git tags `cmd/jv/v0.7.0`
```
Usage: jv [OPTIONS] SCHEMA [INSTANCE...]Options:
-c, --assert-content Enable content assertions with draft >= 7
-f, --assert-format Enable format assertions with draft >= 2019
--cacert pem-file Use the specified pem-file to verify the peer. The file may contain multiple CA certificates
-d, --draft version Draft version used when '$schema' is missing. Valid values 4, 6, 7, 2019, 2020 (default 2020)
-h, --help Print help information
-k, --insecure Use insecure TLS connection
-o, --output format Output format. Valid values simple, alt, flag, basic, detailed (default "simple")
-q, --quiet Do not print errors
-v, --version Print build information
```- [x] exit code `1` for validation errors, `2` for usage errors
- [x] validate both schema and multiple instances
- [x] support both json and yaml files
- [x] support standard input, use `-`
- [x] quite mode with parsable output
- [x] http(s) url support
- [x] custom certs for validation, use `--cacert`
- [x] flag to skip certificate verification, use `--insecure`