Docs · Validators
gtin validator
GS1 GTIN-8/12/13/14 with trailing-digit checksum.
Reference
Format
Strips whitespace, then matches 8, 12, 13, or 14 digits and verifies the GS1 mod-10 trailing-digit checksum.
Examples
- 7613034626844 (GTIN-13, EAN)
- 00012345600012 (GTIN-14, SSCC-style)
- 0123456789012 (GTIN-13 with leading zero — keep as string!)
How it runs
Implementation
Faithful summary of lib/validators.ts. Validators are pure functions and run identically in the worker, the Workbench, and the MCP server.
function validGtin(value) {
const v = value.replace(/\s+/g, '')
if (!/^\d{8}$|^\d{12,14}$/.test(v)) {
return fail('gtin_format', 'expected 8/12/13/14 digits')
}
const digits = v.split('').map(Number)
const check = digits.pop()
const sum = digits.reverse().reduce(
(acc, d, i) => acc + d * (i % 2 === 0 ? 3 : 1), 0,
)
const want = (10 - (sum % 10)) % 10
return check === want ? OK : fail('gtin_checksum', 'bad GTIN checksum')
}Config
Use in a template
Validators attach to a field on a custom template. The cascade runs them after mapping but before commit; failures surface in the per-row validation report.
fields:
- column: gtin
type: string
validators:
- type: gtinWatch out
Common gotchas
- Leading zeros are significant. Always send GTINs as strings — Excel/JSON parsers that coerce to number will silently drop them and fail the format check.
- GTIN-11 is intentionally not accepted (not a GS1 form). GTIN-9, 10 are also rejected.
- The reserved Restricted Circulation range (RCN) passes if the checksum is valid; we do not flag GS1 prefix semantics.
Catalogue
Related templates
- Drug formulary
drug_formulary_v1ATC/GTIN-coded drug catalog. Emits FHIR Medication.
Fields:
gtin - Supplier inventory
supplier_inventory_v1Supplier catalogue with GTIN/IBAN/GLN.
Fields:
gtin - Products
products_v1Product catalog: SKU, GTIN, price, category, weight, stock flag.
Fields:
gtin
Pricing
Validators run on every committed row
Validators add no AI cost — they are pure functions. Every map bills a small flat per-map fee from your prepaid token wallet ($10 minimum, shared across our suite); only columns that reach the metered LLM layer, plus any-to-any convert and reshape, bill real AI tokens. See pricing →
Explore
Other validators
Back to the documentation index or browse the template catalogue.
Ready when you are
Validate every row — before it lands.
Attach checksum-strict validators to any field, and gate risky commits with the requires_hitl flag. One key runs the whole cascade.