ChemPal Documentation - v1.6.0
    Preparing search index...
    • Type guard to validate if a value is a known ISO 3166-1 alpha-2 country code. Checks the value against country-list-js so any real country code is accepted.

      Parameters

      • country: unknown

        The value to validate

      Returns country is valueof<any>

      Type predicate indicating if the value is a valid country code

      isCountryCode("US") // true
      isCountryCode("ZZ") // false
      isCountryCode(undefined) // false
      export function isCountryCode(country: unknown): country is CountryCode {
      return typeof country === 'string' && findCountryByIso2(country) !== undefined;
      }