Expand description
Field-level validators.
Standalone helpers invoked from generated validate methods on
Create / Update input structs. Each returns Ok(()) on success or
a redacted CoolError::Validation whose public message names
the field but never echoes the rejected value (so PII does not
leak via 422 bodies).
Functions§
- validate_
email - Pragmatic email check: requires exactly one
@, non-empty local and domain parts, at least one.in the domain, and no whitespace. Not a full RFC 5322 grammar — that grammar admits forms (quoted local parts, IP literals) banks rarely accept anyway. Reject early; let real KYC flows do deeper validation. - validate_
iso4217 - ISO 4217 currency codes are 3 ASCII uppercase letters. We do not enforce the registered set here — that table churns and is downstream policy. Banks typically pin allowed currencies via a separate allow-list anyway.
- validate_
length - validate_
range_ decimal - Decimal-typed
@rangeenforcement. The parser accepts integer bounds (@range(min: 0, max: 100)) on both Int and Decimal fields; the i64 bounds are promoted to Decimal here so monetary fields can declare the same shape as integer counters. Banks routinely write things likeamount Decimal @range(min: 0)to forbid negative amounts at the framework layer — without this, the validator silently no-ops and out-of-range values reach the database. - validate_
range_ i64 - validate_
uri