CountrySchemaclass
new CountrySchema({ one = "country", title = "Country", value = "detect", ...options }: CountrySchemaOptions = {})| Param | Type | |
|---|---|---|
options | CountrySchemaOptions | Options for CountrySchema. Defaults to {} |
.value | PossibleCountry | 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 ofCOUNTRIES. - A
valueof"detect"resolves the default country from the browser language.
Examples
const schema = new CountrySchema({});
schema.validate("GB"); // "GB"