@nostrability/schemata v0.1.1
Note: This package will be migrated to nostrability/schemata once all events that @nostrwatch tests have a schema specified.
@nostrwatch/schemata
A template for simplifying the validation of nostr events, their attributes and their respective tags using JSON-Schema standards.
Related
@nostrwatch/schemata-js-ajv
- Typescript library for validating nostr events, depends on this package.
Usage
- Download ZIP file (all languages) or include package (js only for now)
- Validate
.json
schemas against nostr events.
Use in your own pipline
You shouldn't. You should write a wrapper or use one that already exists. Wrappers must use the following typings.
type NSchemaResult [ boolean, NSchemaMessage[] ]
interface NSchemaMessage {
level: "info" | "warning" | "error"
message: string
}
And provide the following interface:
validate(event: NostrEvent): NSchemaResult
validateMany(events: NostrEvent[]): NSchemaResult[]
Contribute
Setup
- Fork the repo.
pnpm install
pnpm build
pnpm test
Writing Schemas
Familiarize yourself with the aliases section and the file structure. 1. Create a new directory for your NIP, and a directory for each kind. ...this is going to be annoying to write, so it should probbaly be automated.
FS Conventions
This toolkit uses path conventions for build and testing schemata.
nips/nip-XY/kind-N/schema.yaml
Kinds are assumed to belong to a NIP, but if you are working with an experimental kind, you won't have a NIP. For these situations, simply place the kind into a nipless "nipless"
nips/nipless/kind-X
5 months ago