{"id":48093968,"url":"https://github.com/nostrability/schemata-validator-rs","last_synced_at":"2026-04-04T15:34:06.613Z","repository":{"id":345793630,"uuid":"1180040167","full_name":"nostrability/schemata-validator-rs","owner":"nostrability","description":"rust jsonschema validator for schemata","archived":false,"fork":false,"pushed_at":"2026-03-20T19:21:40.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-21T08:59:09.469Z","etag":null,"topics":["json-schema-validator","nostr","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nostrability.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-12T16:30:39.000Z","updated_at":"2026-03-21T04:45:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nostrability/schemata-validator-rs","commit_stats":null,"previous_names":["nostrability/schemata-validator-rs"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/nostrability/schemata-validator-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nostrability%2Fschemata-validator-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nostrability%2Fschemata-validator-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nostrability%2Fschemata-validator-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nostrability%2Fschemata-validator-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nostrability","download_url":"https://codeload.github.com/nostrability/schemata-validator-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nostrability%2Fschemata-validator-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31403959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema-validator","nostr","rust"],"created_at":"2026-04-04T15:34:06.368Z","updated_at":"2026-04-04T15:34:06.593Z","avatar_url":"https://github.com/nostrability.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# schemata-validator-rs\n\nRust validator for [Nostr](https://nostr.com/) protocol JSON schemas. This is the Rust equivalent of [`@nostrwatch/schemata-js-ajv`](https://github.com/sandwichfarm/nostr-watch), built on top of [`schemata-rs`](https://github.com/nostrability/schemata-rs).\n\nValidates Nostr events, NIP-11 documents, and protocol messages against the canonical [schemata](https://github.com/nostrability/schemata) definitions using Draft 7 JSON Schema.\n\n## Related projects\n\n| Project | Language | Role |\n|---------|----------|------|\n| [nostrability/schemata](https://github.com/nostrability/schemata) | JSON/JS | Canonical schema definitions |\n| [schemata-rs](https://github.com/nostrability/schemata-rs) | Rust | Data crate (schemas + registry) |\n| [@nostrwatch/schemata-js-ajv](https://github.com/sandwichfarm/nostr-watch) | JS/TS | JS validator (AJV-based) |\n\n## When to use this\n\nJSON Schema validation is [not suited for runtime hot paths](https://github.com/nostrability/schemata#what-is-it-not-good-for) — it's slow by design due to the breadth of the specification. Use this crate in **CI and integration tests** to catch schema drift at build time, not in production event processing.\n\nGood for:\n- CI pipelines that verify your event construction matches the canonical schemas\n- Integration tests for clients and relays\n- Fuzz testing to discover broken event shapes\n\nNot good for:\n- Validating every incoming event at runtime\n- Hot paths where latency matters\n\n## Usage\n\nAdd as a **dev dependency** in your `Cargo.toml`:\n\n```toml\n[dev-dependencies]\nschemata-validator-rs = { git = \"https://github.com/nostrability/schemata-validator-rs.git\" }\nschemata-rs = { git = \"https://github.com/nostrability/schemata-rs.git\" }\n\n# Required until schemata-rs is published on crates.io\n[patch.\"https://github.com/nostrability/schemata-validator-rs.git\"]\nschemata-rs = { git = \"https://github.com/nostrability/schemata-rs.git\" }\n```\n\n### Example: validate event construction in tests\n\n```rust\nuse schemata_validator_rs::{validate_note, validate, get_schema};\n\n#[test]\nfn my_event_matches_schema() {\n    let event = serde_json::json!({\n        \"id\": \"aa\".repeat(32),\n        \"pubkey\": \"bb\".repeat(32),\n        \"created_at\": 1700000000u64,\n        \"kind\": 1,\n        \"tags\": [],\n        \"content\": \"hello world\",\n        \"sig\": \"cc\".repeat(64)\n    });\n\n    let result = validate_note(\u0026event);\n    assert!(result.valid, \"errors: {:?}\", result.errors);\n}\n\n#[test]\nfn my_nip11_doc_matches_schema() {\n    use schemata_validator_rs::validate_nip11;\n\n    let result = validate_nip11(\u0026serde_json::json!({\n        \"name\": \"My Relay\",\n        \"supported_nips\": [1, 11]\n    }));\n    assert!(result.valid);\n}\n\n#[test]\nfn relay_message_matches_schema() {\n    use schemata_validator_rs::{validate_message, Subject};\n\n    let msg = serde_json::json!([\"NOTICE\", \"rate limited\"]);\n    let result = validate_message(\u0026msg, Subject::Relay, \"Notice\");\n    assert!(result.valid);\n}\n\n#[test]\nfn tag_matches_schema() {\n    let schema = get_schema(\"pTagSchema\").unwrap();\n    let tag = serde_json::json!([\"p\", \"aa\".repeat(32)]);\n    let result = validate(schema, \u0026tag);\n    assert!(result.valid);\n}\n```\n\n### Example: CI workflow\n\n```yaml\n# .github/workflows/schema-validation.yml\nname: Schema Validation\non: [push, pull_request]\njobs:\n  validate:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: dtolnay/rust-toolchain@stable\n      - run: cargo test --test schema_validation\n```\n\nFor a full working example, see [bugstr](https://github.com/alltheseas/bugstr).\n\n## API\n\n| Function | Description |\n|----------|-------------|\n| `validate(schema, data)` | Validate data against any JSON schema |\n| `validate_note(event)` | Validate a Nostr event (looks up `kind{N}Schema`) |\n| `validate_nip11(doc)` | Validate a NIP-11 relay info document |\n| `validate_message(msg, subject, slug)` | Validate a relay/client protocol message |\n| `get_schema(key)` | Look up a schema from the registry |\n\n### ValidationResult\n\n```rust\nstruct ValidationResult {\n    valid: bool,           // true if no errors\n    errors: Vec\u003c…\u003e,        // schema violations\n    warnings: Vec\u003c…\u003e,      // additional properties, missing schemas\n}\n```\n\nErrors are hard schema violations. Warnings flag additional properties not in the schema and unknown kinds/message types.\n\n## License\n\nGPL-3.0-or-later\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnostrability%2Fschemata-validator-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnostrability%2Fschemata-validator-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnostrability%2Fschemata-validator-rs/lists"}