Files
zeekay a86165b198 feat: hello + validate-email + policy-eval examples
Three end-to-end examples mirroring zip-rs:
 - hello       — minimal name → greeting handler (1.5 KB built)
 - validate-email — port of the canonical validate fixture, byte-equivalent
                    JSON output to base/plugins/extbench/fixtures/goja-js (1.9 KB)
 - policy-eval — realistic IAM/gateway authz decision handler (2.0 KB)

Built JS is committed so test harnesses + downstream consumers don't
depend on the toolchain. scripts/build-example.mjs is the monorepo
build driver (aliases @hanzo/zip to the local dist); end users use
the published npx zip-js build instead.

scripts/verify-examples.mjs loads each built bundle into a fresh V8
context and asserts byte-for-byte JSON output matches the canonical
reference strings — the same shape extbench compares.
2026-05-18 22:04:15 -07:00
..

validate-email

TypeScript port of the canonical validate-email fixture. Produces byte-equivalent JSON output to the AssemblyScript, Rust, and plain-JS reference fixtures in base/plugins/extbench/fixtures/.

npm install
npm run build      # writes ./validate.js next to extension.json

The output validate.js is the goja-loadable JS module — drop it next to extension.json and any HIP-0105 goja host can invoke it.

Byte equivalence

Input Output
{"email":"[email protected] ","age":25} {"ok":true,"email":"[email protected]","age":25}
{"email":"","age":25} {"ok":false,"error":"email required"}
{"email":"[email protected]","age":-1} {"ok":false,"error":"age out of range"}
{"email":"bad","age":30} {"ok":false,"error":"email shape"}
{"email":"a@nodot","age":30} {"ok":false,"error":"email domain"}