Docs · Validators
date_range validator
Parse a date and bound it between optional min/max.
Reference
Format
Anything `Date.parse()` accepts. Bounds may be ISO date strings (`1900-01-01`), full ISO timestamps, or the literal `today` which resolves to `Date.now()` at validation time.
Examples
- min: '1900-01-01', max: 'today' // date of birth
- min: 'today' // future-only (appointments)
- max: '2099-12-31' // open-ended past
How it runs
Implementation
A faithful summary of lib/validators.ts. Validators are pure functions and run identically in the Worker, the Workbench and the MCP server — one implementation, so the three cannot disagree about whether a value is valid.
function validDateRange(value, params) {
const t = Date.parse(value)
if (Number.isNaN(t)) return fail('date_invalid', 'not a parseable date')
const min = params.min === 'today' ? Date.now()
: params.min ? Date.parse(params.min) : -Infinity
const max = params.max === 'today' ? Date.now()
: params.max ? Date.parse(params.max) : Infinity
if (t < min) return fail('date_too_early', `before ${params.min}`)
if (t > max) return fail('date_too_late', `after ${params.max}`)
return OK
}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: date_of_birth
type: date
format: auto
validators:
- type: date_range
min: '1900-01-01'
max: todayWatch out
Common gotchas
- Parsing is engine-dependent. `Date.parse("13/06/2024")` returns NaN in V8. Use ISO `YYYY-MM-DD` or pre-format in your transform.
- `today` resolves at validation time, not request time — there is no caching across rows in a batch.
- Time zone: bare dates parse as UTC midnight. A `min: today` boundary in non-UTC zones can reject rows that "look" current locally.
Where it runs
Three routes, no AI cost.
- POST
/v1/validate-rowValidate one row against a template. Stateless, no key, pure compute — the fastest way to try date_range against a real value.no key - POST
/v1/uploads/:id/validateRun every field validator over the parsed upload, without committing. Returns errors and warnings per row.read - POST
/v1/uploads/:id/commitValidates on the way out.skip_invalid_rowsdrops the failures instead of failing the commit.commit
Validators are pure functions, so they add nothing to the AI bill. Every map draws a small flat per-map fee from your prepaid token wallet ($10 minimum, shared across the phi-cloud suite); only columns that reach the metered LLM layer, plus any-to-any convert and structural reshape, bill real AI tokens. See pricing
Catalogue
Related templates
- Patient demographics
patient_demographics_v1Patient identity. Emits FHIR Patient.
Fields ·
date_of_birth - KYC profiles
kyc_profiles_v1Know-Your-Customer identity profiles with risk rating. Contains PII.
Fields ·
date_of_birth
Explore
All 19 validator types
The complete list a template field can declare. There is no SNOMED validator — it required an affiliate licence, no template used it, and it was removed in 2026.
- date_range
- regex
- enum
- number_range
- phone
- url
- iban
- bic
- uuid
- gtin
- pharmacode
- fhir_reference
- loinc_code
- icd10_code
- atc_code
- cpt_code
- npi
- gln
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 behind the requires_hitl flag. One key runs the whole cascade.