+1
-1
packages/lexicon-rs/Cargo.lock
+1
-1
packages/lexicon-rs/Cargo.lock
+1
-1
packages/lexicon-rs/Cargo.toml
+1
-1
packages/lexicon-rs/Cargo.toml
+21
-15
packages/lexicon-rs/README.md
+21
-15
packages/lexicon-rs/README.md
···
4
5
## Overview
6
7
-
This validation engine can be used in any project that needs AT Protocol lexicon validation. It provides high-performance, spec-compliant validation of AT Protocol lexicon documents and data records. It can also be compiled to WebAssembly for use in JavaScript/TypeScript environments.
8
9
## Architecture
10
11
-
This package serves as the core validation engine and is typically consumed by higher-level packages:
12
13
- **`@slices/lexicon`** - TypeScript/Deno package with ergonomic APIs
14
- **`lexicon-intellisense`** - VS Code extension for lexicon development
15
-
- **Slices CLI** - Command-line tooling for lexicon management
16
17
## Features
18
···
31
32
```toml
33
[dependencies]
34
-
slices-lexicon = "0.1"
35
```
36
37
Basic validation:
···
92
93
```javascript
94
import init, {
95
-
WasmLexiconValidator,
96
-
validate_lexicons_and_get_errors,
97
-
is_valid_nsid
98
-
} from './pkg/slices_lexicon.js';
99
100
await init();
101
102
// Validate lexicons
103
const lexicons = [{
104
-
id: "com.example.post",
105
-
lexicon: 1,
106
-
defs: { /* ... */ }
107
}];
108
109
const errors = validate_lexicons_and_get_errors(JSON.stringify(lexicons));
110
-
console.log('Validation errors:', JSON.parse(errors));
111
112
// Validate NSID format
113
const isValid = is_valid_nsid("com.example.post");
···
115
116
## JavaScript/TypeScript Usage
117
118
-
If you're using JavaScript or TypeScript, use the higher-level packages instead of consuming this library directly:
119
120
-
- **TypeScript/JavaScript**: Use `@slices/lexicon` for ergonomic APIs with automatic resource management
121
- **VS Code Development**: Install the `lexicon-intellisense` extension
122
- **CLI Tools**: Use the Slices CLI for lexicon management tasks
123
···
151
152
## License
153
154
-
MIT
···
4
5
## Overview
6
7
+
This validation engine can be used in any project that needs AT Protocol lexicon
8
+
validation. It provides high-performance, spec-compliant validation of AT
9
+
Protocol lexicon documents and data records. It can also be compiled to
10
+
WebAssembly for use in JavaScript/TypeScript environments.
11
12
## Architecture
13
14
+
This package serves as the core validation engine and is typically consumed by
15
+
higher-level packages:
16
17
- **`@slices/lexicon`** - TypeScript/Deno package with ergonomic APIs
18
+
- **`@slices/cli`** - Deno command-line tool for lexicon/appview management
19
- **`lexicon-intellisense`** - VS Code extension for lexicon development
20
21
## Features
22
···
35
36
```toml
37
[dependencies]
38
+
slices-lexicon = "0.2"
39
```
40
41
Basic validation:
···
96
97
```javascript
98
import init, {
99
+
is_valid_nsid,
100
+
validate_lexicons_and_get_errors,
101
+
WasmLexiconValidator,
102
+
} from "./pkg/slices_lexicon.js";
103
104
await init();
105
106
// Validate lexicons
107
const lexicons = [{
108
+
id: "com.example.post",
109
+
lexicon: 1,
110
+
defs: {/* ... */},
111
}];
112
113
const errors = validate_lexicons_and_get_errors(JSON.stringify(lexicons));
114
+
console.log("Validation errors:", JSON.parse(errors));
115
116
// Validate NSID format
117
const isValid = is_valid_nsid("com.example.post");
···
119
120
## JavaScript/TypeScript Usage
121
122
+
If you're using JavaScript or TypeScript, use the higher-level packages instead
123
+
of consuming this library directly:
124
125
+
- **TypeScript/JavaScript**: Use `@slices/lexicon` for ergonomic APIs with
126
+
automatic resource management
127
- **VS Code Development**: Install the `lexicon-intellisense` extension
128
- **CLI Tools**: Use the Slices CLI for lexicon management tasks
129
···
157
158
## License
159
160
+
MIT
packages/lexicon-rs/test_ref_validation
packages/lexicon-rs/test_ref_validation
This is a binary file and will not be displayed.
-52
packages/lexicon-rs/test_ref_validation.rs
-52
packages/lexicon-rs/test_ref_validation.rs
···
1
-
use serde_json::json;
2
-
use slices_lexicon::validate;
3
-
4
-
fn main() {
5
-
let broken_lexicon = json!({
6
-
"lexicon": 1,
7
-
"id": "network.slices.slice.getSyncSummary",
8
-
"defs": {
9
-
"main": {
10
-
"type": "query",
11
-
"description": "Get a summary",
12
-
"output": {
13
-
"encoding": "application/json",
14
-
"schema": {
15
-
"type": "object",
16
-
"required": ["collectionsSummary"],
17
-
"properties": {
18
-
"collectionsSummary": {
19
-
"type": "array",
20
-
"items": {
21
-
"type": "ref",
22
-
"ref": "#collectionSummar"
23
-
}
24
-
}
25
-
}
26
-
}
27
-
}
28
-
},
29
-
"collectionSummary": {
30
-
"type": "object",
31
-
"required": ["collection"],
32
-
"properties": {
33
-
"collection": {
34
-
"type": "string"
35
-
}
36
-
}
37
-
}
38
-
}
39
-
});
40
-
41
-
let lexicons = vec![broken_lexicon];
42
-
43
-
match validate(lexicons) {
44
-
Ok(()) => println!("✅ Validation passed (should NOT happen with broken ref)"),
45
-
Err(errors) => {
46
-
println!("❌ Validation failed (expected):");
47
-
for (lexicon_id, error_list) in errors {
48
-
println!(" {}: {:?}", lexicon_id, error_list);
49
-
}
50
-
}
51
-
}
52
-
}
···