@classytic/validation
v0.6.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). Subpaths: barcode, identifiers, mon
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).
@classytic/validation/money
currencyCode, minorAmount(sign), moneyFields(sign), money(sign),
moneySchema, signedMoneySchema, moneyByCurrencySchema, fxSnapshotSchema,
fxWireSchema, plus isMinorUnits and the mongooseMinorUnits validator that
calls it.
@classytic/validation/monetization
monetizationSchema (the discriminated union mirroring
@classytic/primitives/monetization) and revenueMonetizationTypeSchema.
No root barrel
There is no . export — always import a subpath. A flat re-export of every
module defeats the per-module tree-shaking a browser bundle needs, and it had
zero importers. (Removed in 0.5.0, along with the ./payment and ./retention
subpaths — see the CHANGELOG for where each rule went.)
Trademark
Code is MIT-licensed. "Classytic"/"arc" names + logos are trademarks of Classytic LLC — see TRADEMARK.md.
