Docs · Validators
pharmacode validator
Swiss pharmacode — 4 to 7-digit local drug identifier.
Reference
Format
Matches `/^\d{4,7}$/`. Digits only, length 4 through 7 inclusive.
Examples
- 1234
- 7680411180014 (NO — this is GTIN, not pharmacode)
- 5396512
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 validPharmacode(value) {
return /^\d{4,7}$/.test(value)
? OK
: fail('pharmacode_format', 'expected 4–7 digits')
}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: pharmacode
type: string
validators:
- type: pharmacodeWatch out
Common gotchas
- Pharmacode has no published checksum, so we cannot detect transposition errors. Pair with a downstream lookup if accuracy matters.
- Do not confuse with GTIN — the Swiss drug GTIN starts `7680` and is 13 digits. Pharmacode is 4–7 digits, standalone.
- Leading zeros are valid pharmacode digits. Send as a string.
Catalogue
Related templates
- Drug formulary
drug_formulary_v1ATC/GTIN-coded drug catalog. Emits FHIR Medication.
Fields:
pharmacode
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.