@classytic/validation
v0.1.0
Published
Isomorphic zod validation schemas shared server<->client. Framework-agnostic, zod the only peer, so the same rules run in the catalog kernel (server auto-CRUD, repository writes) and in admin/storefront forms (browser). First module: barcode (GTIN/EAN/UPC
Readme
@classytic/validation
Isomorphic zod validation schemas shared server↔client. Framework-agnostic
(zod is the only peer), so the same rules run in the catalog kernel (Arc
auto-CRUD, repository writes) and in admin/storefront forms — one
implementation, zero drift.
Charter: zod-based validation shared between server and client lives here.
Zod-free value objects / pure functions belong in @classytic/primitives;
wire/transport types in @classytic/repo-core.
Modules
@classytic/validation/barcode
import {
validateGTIN,
validateISBN,
detectBarcodeFormat,
optionalScannableBarcodeSchema,
} from "@classytic/validation/barcode";
validateGTIN("4006381333931"); // true
detectBarcodeFormat("9780306406157"); // "ISBN13"
const product = z.object({ barcode: optionalScannableBarcodeSchema });| Format | Length | Checksum |
|---|---|---|
| EAN-13 | 13 | mod-10 (1,3,1,3…) |
| EAN-8 | 8 | mod-10 (3,1,3,1…) |
| UPC-A | 12 | mod-10 (3,1,3,1…) |
| GTIN-14 | 14 | mod-10 (3,1,3,1…) |
| ISBN-10 | 10 (or 9+X) | mod-11 |
| ISBN-13 | 13 (978/979) | EAN-13 |
| CODE128 | ≥4 | printable ASCII (no checksum) |
@classytic/validation/identifiers
productIdentifiersSchema — a product's standard IDs (gtin/upc/ean/isbn
checksum-validated, mpn/plu length-only, custom open map).
Both modules are also re-exported flat from the package root
(@classytic/validation).
