requireCountry()function

requireCountry(value?: unknown, caller: AnyCaller = requireCountry): Country
ParamType
valueunknown
The country code to parse, or "detect" to read it from the browser.
callerAnyCaller
Identity of the calling function for error attribution. Defaults to requireCountry
Return
Country
The matching Country code.
Throws
unknown
RequiredError If a country could not be resolved.

Parse a country string, or detect a browser country from navigator.language, or throw RequiredError.

Examples

requireCountry("gb") // "GB"