CountrySchemaclass

new CountrySchema({ one = "country", title = "Country", value = "detect", ...options }: CountrySchemaOptions = {})
ParamType
optionsCountrySchemaOptions
Options for CountrySchema. Defaults to {}
    .valuePossibleCountry
Country value, or "detect" to resolve from browser language. readonly
Return
CountrySchema
Schema that defines a valid ISO 3166 country code, e.g. GB.

Schema that defines a valid ISO 3166 country code, e.g. GB.

  • The input is coerced with getCountry(), then checked against the known set of COUNTRIES.
  • A value of "detect" resolves the default country from the browser language.

Examples

const schema = new CountrySchema({});
 schema.validate("GB"); // "GB"