Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdakkota/jsonschema
JSON Schema Draft 4 validator implementation. Powered by go-faster/jx.
https://github.com/tdakkota/jsonschema
draft4 json jsonschema schema validate validation validator
Last synced: 12 days ago
JSON representation
JSON Schema Draft 4 validator implementation. Powered by go-faster/jx.
- Host: GitHub
- URL: https://github.com/tdakkota/jsonschema
- Owner: tdakkota
- License: apache-2.0
- Created: 2022-05-29T03:35:26.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-10T20:56:35.000Z (8 months ago)
- Last Synced: 2024-10-18T21:16:32.620Z (20 days ago)
- Topics: draft4, json, jsonschema, schema, validate, validation, validator
- Language: Go
- Homepage:
- Size: 2.89 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonschema
[![Go Reference](https://pkg.go.dev/badge/github.com/tdakkota/jsonschema.svg)](https://pkg.go.dev/github.com/tdakkota/jsonschema)
[![codecov](https://codecov.io/gh/tdakkota/jsonschema/branch/master/graph/badge.svg)](https://codecov.io/gh/tdakkota/jsonschema)jsonschema is a [JSON Schema Draft 4](https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00)
validator implementation## Usage
```go
package exampleimport (
"fmt""github.com/tdakkota/jsonschema"
)func Example() {
schema, err := jsonschema.Parse([]byte(`{
"type": "object",
"properties": {
"number": { "type": "number" },
"street_name": { "type": "string" },
"street_type": { "enum": ["Street", "Avenue", "Boulevard"] }
}
}`))
if err != nil {
panic(err)
}if err := schema.Validate(
[]byte(`{ "number": 1600, "street_name": "Pennsylvania", "street_type": "Avenue" }`),
); err != nil {
panic(err)
}fmt.Println(schema.Validate([]byte(`{"number": "1600"}`)))
// Output:
// object: "number": string: type is not allowed
}
```## Install
```
go get -d github.com/tdakkota/jsonschema
```## Roadmap
See [this issue](https://github.com/tdakkota/jsonschema/issues/4).