Go validator for Nostr protocol JSON schemas. Built on top of schemata-go.
JSON Schema validation is not suited for runtime hot paths. Use this in CI and integration tests.
import validator "github.com/nostrability/schemata-validator-go"
func TestMyEvent(t *testing.T) {
event := []byte(`{"id":"aa...","pubkey":"bb...","created_at":1700000000,"kind":1,"tags":[],"content":"hello","sig":"cc..."}`)
result := validator.ValidateNote(event)
if !result.Valid {
t.Fatalf("errors: %+v", result.Errors)
}
}| Function | Description |
|---|---|
Validate(schema, data) |
Validate data against any JSON schema |
ValidateNote(event) |
Validate a Nostr event (looks up kind{N}Schema) |
ValidateNip11(doc) |
Validate a NIP-11 relay info document |
ValidateMessage(msg, subject, slug) |
Validate a relay/client protocol message |
GetSchema(key) |
Look up a schema from the registry |
GPL-3.0-or-later