https://github.com/yu-icchi/go-jsonschema-validator
https://github.com/yu-icchi/go-jsonschema-validator
go-library golang json-schema jsonschema validator
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yu-icchi/go-jsonschema-validator
- Owner: yu-icchi
- Created: 2017-08-04T17:50:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-02T16:48:25.000Z (almost 9 years ago)
- Last Synced: 2026-01-29T16:37:52.007Z (5 months ago)
- Topics: go-library, golang, json-schema, jsonschema, validator
- Language: Go
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-jsonschema-validator
[](https://travis-ci.org/yu-ichiko/go-jsonschema-validator)
supported draft 4 and draft 6
```go
type Sample struct {
Name string `json:"name" jsonschema:"pattern:[a-zA-Z0-9],maxLength:20"`
Age int `json:"age" jsonschema:"minimum:0,maximum:20"`
}
sample := Sample{
Name: "test",
Age: 10,
}
validator := jsonschema.NewValidator()
validator.AddFormat("my-format", func(value *reflect.Value, field *reflect.StructField) (err error) {
...
return
})
err := validator.Validate(sample)
```