> ## Documentation Index
> Fetch the complete documentation index at: https://validity-kt.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Location

> Countries, languages, locales, time zones, coordinates and postal codes.

Where something is, or which language it speaks. `postalCode(country)` knows the formats of 72 countries, by their
ISO 3166-1 alpha-2 code, and checks nothing when the country is `null` or unknown, so the rule can follow a country
field that may be missing.

```kotlin Store.kt theme={null}
data class Store(
    val country: String?,
    val zipCode: String?,
    val position: String?,
    val timeZone: String?,
    val locale: String?
) : Validatable {
    override fun validation() = validation {
        ::country required { isoCountryCode() }
        ::zipCode required { postalCode(country) }
        ::position required { coordinates() }
        ::timeZone required { timeZone() }
        ::locale required { locale() }
    }
}
```

| Constraint | Checks |
| - | - |
| [`isoCountryCode`](#isocountrycode) | Is an ISO 3166-1 alpha-2 country code, such as `BR`, in uppercase. |
| [`isoCountryCodeAlpha3`](#isocountrycodealpha3) | Is an ISO 3166-1 alpha-3 country code, such as `BRA`, in uppercase. |
| [`languageCode`](#languagecode) | Is an ISO 639-1 language code, such as `pt`, in lowercase. |
| [`locale`](#locale) | Is a well-formed IETF BCP 47 language tag, such as `pt-BR` or `zh-Hant-TW`. |
| [`timeZone`](#timezone) | Is a time zone id the JVM knows, such as `America/Sao_Paulo` or `UTC`. |
| [`latitude`](#latitude) | Is a latitude, from -90 to 90. |
| [`longitude`](#longitude) | Is a longitude, from -180 to 180. |
| [`coordinates`](#coordinates) | Is a latitude from -90 to 90 and a longitude from -180 to 180, separated by a comma, such as `-23.5505, -46.6333`. |
| [`postalCode`](#postalcode) | Is a postal code of `country`. |

## Countries and languages

### `isoCountryCode`

`isoCountryCode()` on `String`

Checks that the string is an ISO 3166-1 alpha-2 country code, such as `BR`, in uppercase.

**Code** `isoCountryCode`· **Message** `must be a valid ISO 3166-1 alpha-2 country code` · **Change it** `isoCountryCode = "…"`

### `isoCountryCodeAlpha3`

`isoCountryCodeAlpha3()` on `String`

Checks that the string is an ISO 3166-1 alpha-3 country code, such as `BRA`, in uppercase.

**Code** `isoCountryCodeAlpha3`· **Message** `must be a valid ISO 3166-1 alpha-3 country code` · **Change it** `isoCountryCodeAlpha3 = "…"`

### `languageCode`

`languageCode()` on `String`

Checks that the string is an ISO 639-1 language code, such as `pt`, in lowercase.

The withdrawn codes `in`, `iw`, `ji` and `mo` fail.

**Code** `languageCode`· **Message** `must be a valid ISO 639-1 language code` · **Change it** `languageCode = "…"`

### `locale`

`locale()` on `String`

Checks that the string is a well-formed IETF BCP 47 language tag, such as `pt-BR` or `zh-Hant-TW`.

**Code** `locale`· **Message** `must be a valid locale` · **Change it** `locale = "…"`

### `timeZone`

`timeZone()` on `String`

Checks that the string is a time zone id the JVM knows, such as `America/Sao_Paulo` or `UTC`.

**Code** `timeZone`· **Message** `must be a valid time zone` · **Change it** `timeZone = "…"`

## Latitude and longitude

### `latitude`

`latitude()` on `Double`, `Float`, `BigDecimal`, `String`

Checks that the number is a latitude, from -90 to 90.

**Code** `latitude`· **Message** `must be a valid latitude` · **Change it** `latitude = "…"`

### `longitude`

`longitude()` on `Double`, `Float`, `BigDecimal`, `String`

Checks that the number is a longitude, from -180 to 180.

**Code** `longitude`· **Message** `must be a valid longitude` · **Change it** `longitude = "…"`

### `coordinates`

`coordinates()` on `String`

Checks that the string is a latitude from -90 to 90 and a longitude from -180 to 180, separated by a comma, such as `-23.5505, -46.6333`.

**Code** `coordinates`· **Message** `must be a valid latitude and longitude pair` · **Change it** `coordinates = "…"`

## Postal codes

### `postalCode`

`postalCode(country)` on `String`

Checks that the string is a postal code of `country`.

When `country` is `null` or has no known format, nothing is checked. Codes are known for 72 countries.

**Code** `postalCode`· **Message** `must be a valid postal code for {country}` · **Change it** `postalCode = "…"`

The countries `postalCode` knows: AD, AR, AT, AU, AZ, BA, BD, BE, BG, BR, BY, CA, CH, CN, CO, CZ, DE, DK, DO, DZ, EE,
ES, FI, FR, GB, GR, HR, HT, HU, ID, IE, IL, IN, IR, IS, IT, JO, JP, KE, KR, LI, LK, LT, LU, LV, MC, MG, MT, MX, MY, NL,
NO, NP, NZ, PK, PL, PR, PT, RO, RU, SA, SE, SG, SI, SK, TH, TN, TW, UA, US, ZA and ZM.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.