Docs · Validators
iban validator
Format + mod-97 checksum, with optional country allow-list.
Reference
Format
Strips whitespace and uppercases, then matches `/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/`. If `countries` is set, the 2-letter prefix must be in that list. Final step is the standard IBAN mod-97 = 1 check, computed in 7-char chunks (no BigInt, edge-worker safe).
Examples
- CH93 0076 2011 6238 5295 7 (CH, 21 chars)
- DE89 3704 0044 0532 0130 00 (DE, 22 chars)
- GB82 WEST 1234 5698 7654 32 (GB, 22 chars, alpha bank code)
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 validIban(value, params) {
const v = value.replace(/\s+/g, '').toUpperCase()
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(v)) return fail('iban_format', 'bad IBAN format')
const countries = Array.isArray(params.countries) ? params.countries : null
if (countries && !countries.includes(v.slice(0, 2))) {
return fail('iban_country', `country ${v.slice(0, 2)} not allowed`)
}
const rearranged = v.slice(4) + v.slice(0, 4)
const expanded = rearranged.replace(/[A-Z]/g, (c) => String(c.charCodeAt(0) - 55))
let mod = 0
for (let i = 0; i < expanded.length; i += 7) {
mod = Number(`${mod}${expanded.slice(i, i + 7)}`) % 97
}
return mod === 1 ? OK : fail('iban_checksum', 'IBAN checksum failed')
}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: iban
type: string
validators:
- type: iban
countries: [CH, LI, DE, FR, IT]Watch out
Common gotchas
- Country length is enforced only via the global 4–32 char total (`[A-Z0-9]{11,30}` after the 4-char prefix). Swiss IBANs are 21 chars, German 22, Maltese 31 — the validator does not enforce per-country length.
- Whitespace is stripped before checksum; case is normalised. `"ch93 0076..."` works.
- No bank-code lookup. A syntactically valid IBAN can still point at a closed account.
- Opt-in `strict: true` enforces per-country length against the SWIFT IBAN Registry (CH=21, DE=22, FR=27, GB=22, MT=31, …) in addition to the mod-97 checksum. A wrong length returns `iban_length`; an unrecognised country prefix returns `iban_country`. Default behavior is unchanged.
Catalogue
Related templates
- Employee roster
employee_roster_v1Names, AHV/GLN, contract type, address.
Fields:
iban - Supplier inventory
supplier_inventory_v1Supplier catalogue with GTIN/IBAN/GLN.
Fields:
iban - Bank accounts
bank_accounts_v1Bank account details with IBAN/BIC validation.
Fields:
iban - Employees
employees_v1Employee master records with identity, contact, and bank details. Contains PII.
Fields:
iban - Payroll
payroll_v1Payroll runs: gross salary, pay period, payout bank details. Contains sensitive PII.
Fields:
iban
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.