| Crates.io | tana-validation |
| lib.rs | tana-validation |
| version | 0.1.1 |
| created_at | 2025-11-18 22:00:42.969027+00 |
| updated_at | 2025-11-18 22:07:59.403849+00 |
| description | Shared validation logic for Tana smart contracts with WASM support |
| homepage | |
| repository | https://github.com/tananetwork/tana-validation |
| max_upload_size | |
| id | 1939051 |
| size | 30,446 |
Shared validation and error formatting logic for Tana smart contracts.
npm install @tananetwork/tana-validation
# or
bun add @tananetwork/tana-validation
import init, { format_validation_error } from '@tananetwork/tana-validation';
// Initialize WASM module
await init();
// Format an error
const error = format_validation_error(
"import { console } from 'tana/invalid';", // code
"contract.ts", // file_path
"Invalid Import", // error_kind
1, // line_num
26, // col_num
"Module 'tana/invalid' not found", // message
"Available modules: tana/core, tana/kv", // help
12 // underline_length
);
console.log(error);
[dependencies]
tana-validation = "0.1"
use tana_validation::format_validation_error;
let error = format_validation_error(
"import { console } from 'tana/invalid';",
"contract.ts",
"Invalid Import",
1,
26,
"Module 'tana/invalid' not found",
"Available modules: tana/core, tana/kv",
12,
);
println!("{}", error);
Both Rust and TypeScript/WASM produce identical output:
Validation Error
❌ Invalid Import
┌─ contract.ts:1:26
│
1 │ import { console } from 'tana/invalid';
│ ^^^^^^^^^^^^ Module 'tana/invalid' not found
│
= help: Available modules: tana/core, tana/kv
│
By writing the error formatter once in Rust and compiling to WASM for TypeScript, we get:
# Test Rust code
cargo test
# Build WASM package
wasm-pack build --target bundler --scope tananetwork
# Test WASM in browser
cd pkg && npm link
cd your-project && npm link @tananetwork/tana-validation
Dual-licensed under MIT OR Apache-2.0.