Need help with PostalCodeValidator?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

211 Stars 11 Forks MIT License 13 Commits 0 Opened issues


A validator for postal codes with support for 200+ regions

Services available


Need anything else?

Contributors list

# 336
13 commits


Build Status License Swift Version

A validator for postal codes with support for 200+ regions.

import Foundation
import PostalCodeValidator

if let validator = PostalCodeValidator(locale: .current) { // United States (US) validator.validate(postalCode: "95014") // true validator.validate(postalCode: "22162-1010") // true

validator.validate(postalCode: "1234567") // false
validator.validate(postalCode: "INVALID") // false


// 248 regions supported if let validator = PostalCodeValidator(regionCode: "JP") { // Japan (JP) validator.validate(postalCode: "154-0023") // true validator.validate(postalCode: "12345") // false }

Note: Only the region of a locale is used to determine validation rules. To validate the postal code for a particular region, you can construct a locale using an identifier with the

language code.


  • Swift 4.0+


Swift Package Manager

Add the PostalCodeValidator package to your target dependencies in

import PackageDescription

let package = Package( name: "YourProject", dependencies: [ .package( url: "", from: "0.1.0" ), ] )

Then run the

swift build
command to build your project.

Known Issues

  • Armed forces in Germany (and likely other countries) use special postal codes, which aren't included in the upstream data source. This will cause validation of these postal codes to fail. (Thanks for pointing this out, @timohetzel)

Additional Details

The CLDR previously maintained a list of postal code formats, but that information was deprecated in v27.

Following the guidance of the twitter-cldr-rb project,

sources its information from The most recent release of this software uses information retrieved from the website on November 27, 2019.




Mattt (@mattt)

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.