Skip to the content

Kuni国

Look up countries, codes, names and subdivisions, load country data on demand and mount a native country card.

Kuni (国) is Japanese for a country. About the name

Contents

Reference · Country code validation

isCountryCodefunction

Whether a value is one of the 250 codes exactly as ISO writes it: two capital letters ("JP", and "XK" for Kosovo). Lower case is not a code here; country() in the main entry is the forgiving one.

Import it

import { isCountryCode } from "@johnmorrisdotca/kuni/codes";

Also exported from: @johnmorrisdotca/kuni

Definition

function isCountryCode(value: unknown): value is CountryCode

Parameters

NameTypeDescription
valueunknown

Anything.

Returns

boolean

True for one of the 250 codes; false for anything else, a lower-case code included.

Examples

import { isCountryCode } from "@johnmorrisdotca/kuni/codes";

console.log(isCountryCode("JP"));   // true
console.log(isCountryCode("jp"));   // false
console.log(isCountryCode("XX"));   // false
true
false
false

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kuni 1.4.0.