The ParseError returned by parse() on failure.
Optionallocale: Locale
Target locale. Unsupported values fall back to DEFAULT_LOCALE.
OptionaldocumentName: string
Optional human-readable document name to interpolate
into the {document} slot (e.g. "DUI", "CPF").
A fully-rendered localized error message.
import { parse } from "nationid";
import { getErrorMessage } from "nationid/i18n";
const r = parse("SV_DUI", "12");
if (!r.ok) {
getErrorMessage(r.error, "es", "DUI"); // "El DUI es demasiado corto."
}
getErrorMessage({ kind: "empty" }, "en");
// "Please enter a value."
getErrorMessage({ kind: "invalid_format" }, "pt", "CPF");
// "O formato do CPF não é válido."
Returns a localized human-readable error message for a
ParseError.Falls back to
DEFAULT_LOCALEwhenlocaleis unsupported, and to a generic per-locale message when the errorkindis unknown (forward-compat with future kinds added incore/types.ts).When
documentNameis omitted, the message uses neutral phrasing ("the document"/"el documento"/"o documento").