Expand description
ISO 3166-1 alpha-2 region-code validation.
identity.region (ADR 030) ends up in log fields and metric labels, so
this allowlist is what stops arbitrary bytes (control chars, non-ASCII,
oversized strings) from corrupting them. The config resolver
(decdn_common::config::normalize_region) calls is_valid_region so
every accepted region code is one of this set.
Accepted set:
- All currently-assigned ISO 3166-1 alpha-2 codes, plus the
exceptionally-reserved
XK(Kosovo) which is widely used by EU/IMF. - The user-assigned reserved ranges (
AA,QM–QZ,XA–XZ,ZZ) so operators can pick a private code for air-gapped or testnet deployments without coordinating with ISO.
Case-sensitive — callers must uppercase first. The 2-char length is implicit in the match patterns; any other length is rejected.
Region is the parsed form: trim + uppercase + this allowlist, done once
at the boundary so consumers compare values rather than re-normalizing at
every call site (#1348). Use it wherever a validated code is carried around;
is_valid_region remains for callers that only need the predicate over a
string they already own.
Structs§
- Invalid
Region Region’sFromStrwas given something outside the accepted set.- Region
- A region code that has already passed
is_valid_region, stored in the normalized (uppercase, untrimmed-of-nothing) form.
Functions§
- is_
valid_ region - True iff
codeis a region the network accepts. See module docs for the accepted set.