Useful when you need direct access to the spec's regex, mask, country, or
confidence metadata without going through the wrapped validate/format
helpers. The returned spec is the same singleton instance held in the
internal registry; do not mutate it.
Generic over the document type code: passing a literal narrows the returned
spec to DocumentSpec<"MX_CURP"> so .code keeps its literal type instead
of widening to the whole DocumentTypeCode union. The runtime invariant
REGISTRY.get(code).code === code justifies the cast at the boundary.
Lookup a
DocumentSpecby its stable code.Useful when you need direct access to the spec's regex, mask, country, or confidence metadata without going through the wrapped
validate/formathelpers. The returned spec is the same singleton instance held in the internal registry; do not mutate it.Generic over the document type code: passing a literal narrows the returned spec to
DocumentSpec<"MX_CURP">so.codekeeps its literal type instead of widening to the wholeDocumentTypeCodeunion. The runtime invariantREGISTRY.get(code).code === codejustifies the cast at the boundary.