slices-lexicon
AT Protocol lexicon validation library for Rust, compiled to WebAssembly.
Features
- 🚀 Fast lexicon validation written in Rust
- 🌐 WebAssembly support for browser and Node.js environments
- 📦 Zero JavaScript dependencies
- 🔒 Type-safe validation with comprehensive error messages
- ✅ Full AT Protocol lexicon specification support
Installation
[]
= "0.1"
Usage
In Rust
use ;
use json;
let lexicons = vec!;
let validator = new?;
let record = json!;
validator.validate_record?;
As WebAssembly
Build with wasm-pack:
Then use in JavaScript/TypeScript:
import init from './pkg/slices_lexicon.js';
await ;
const validator = ;
validator.;
Supported Types
- Objects with required/optional fields
- Arrays with min/max length constraints
- Strings with format validation (datetime, URI, DID, handle, etc.)
- Integers with range constraints
- Booleans with const values
- Bytes (base64 encoded)
- Unions (open and closed)
- References (local and cross-lexicon)
- CID links
- Tokens (unit types for type discrimination)
- Unknown types
String Formats
datetime- RFC3339/ISO8601 datetimeuri- Generic URIat-uri- AT Protocol URIdid- Decentralized Identifierhandle- AT Protocol handleat-identifier- DID or handlensid- Name Spaced Identifiercid- Content Identifierlanguage- BCP47 language tagtid- Timestamp-based Identifierrecord-key- Record key format
License
MIT