npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postal-code-validator

v1.0.3

Published

A package for validating postal codes

Downloads

1,929

Readme

Postal Code Validator 📮

npm version build github sponsors

Why Validating Postal Codes is Important

Validating postal codes is crucial for ensuring accurate data in applications that rely on location-based services. Incorrect or improperly formatted postal codes can lead to errors in shipping, geolocation, and data analysis. By validating postal codes, you can improve the reliability and efficiency of your application.

Package Completeness ✅

This TypeScript package provides comprehensive postal code validation functionality. Unlike similar packages, it offers a more thorough validation process, minimizing false positives and ensuring accurate results.

Remaining Development Goals 🛠️

While the package is already robust, there are ongoing efforts to enhance its capabilities:

  • Fix False Positives: Address any false positives in the existing regular expressions to improve accuracy.
  • Exhaustive Unit Tests: Develop a comprehensive suite of unit tests to thoroughly validate the package's functionality and ensure its reliability.
  • Additional API Functionality: Expand the package's API to provide more advanced features and options for users.

Legal Notice 📜

Note for Users: This package is distributed under the GNU General Public License Version 3 (GPL-3.0). This license grants users the freedom to use, modify, and distribute the software, with the condition that any derivative works are also licensed under GPL-3.0. It's important to review and understand the terms of this license before using the package in your projects.

Contributing Guidelines 🤝

Note for Contributors: We welcome contributions to improve and enhance this package. If you'd like to contribute, please follow these guidelines:

  • Write Unit Tests: Ensure any changes or additions are accompanied by corresponding unit tests to maintain code quality and reliability.
  • Development Process: To contribute, open a pull request (PR) targeting the develop branch. This allows for collaborative development and ensures that changes are properly reviewed before merging into the main codebase.

:toolbox: Functions

:gear: countryHasPostalCodeSystem

| Function | Type | | ---------- | ---------- | | countryHasPostalCodeSystem | (country: Country) => boolean |

:gear: isValidCountryPostalCode

| Function | Type | | ---------- | ---------- | | isValidCountryPostalCode | (postalCode: string, country: Country) => boolean |

:gear: isValidPostalCode

| Function | Type | | ---------- | ---------- | | isValidPostalCode | (postalCode: string) => boolean |

:wrench: Constants

:gear: countryRegexMap

| Constant | Type | | ---------- | ---------- | | countryRegexMap | Map<Country, string> |

:nut_and_bolt: Enum

:gear: Country

| Property | Type | Description | | ---------- | ---------- | ---------- | | Afghanistan | 'Afghanistan' | | | AlandIslands | 'Åland Islands' | | | Albania | 'Albania' | | | Algeria | 'Algeria' | | | AmericanSamoa | 'American Samoa' | | | Andorra | 'Andorra' | | | Angola | 'Angola' | | | Anguilla | 'Anguilla' | | | AntiguaAndBarbuda | 'Antigua and Barbuda' | | | Argentina | 'Argentina' | | | Armenia | 'Armenia' | | | Aruba | 'Aruba' | | | AscensionIsland | 'Ascension Island' | | | Australia | 'Australia' | | | Austria | 'Austria' | | | Azerbaijan | 'Azerbaijan' | | | Bahamas | 'Bahamas' | | | Bahrain | 'Bahrain' | | | Bangladesh | 'Bangladesh' | | | Barbados | 'Barbados' | | | Belarus | 'Belarus' | | | Belgium | 'Belgium' | | | Belize | 'Belize' | | | Benin | 'Benin' | | | Bermuda | 'Bermuda' | | | Bhutan | 'Bhutan' | | | Bolivia | 'Bolivia' | | | Bonaire | 'Bonaire' | | | BosniaHerzegovina | 'Bosnia-Herzegovina' | | | Botswana | 'Botswana' | | | BouvetIsland | 'Bouvet Island' | | | Brazil | 'Brazil' | | | BritishAntarcticTerritory | 'British Antarctic Territory' | | | BritishIndianOceanTerritory | 'British Indian Ocean Territory' | | | BritishVirginIslands | 'British Virgin Islands' | | | BruneiDarussalam | 'Brunei Darussalam' | | | Bulgaria | 'Bulgaria' | | | BurkinaFaso | 'Burkina Faso' | | | Burundi | 'Burundi' | | | Cambodia | 'Cambodia' | | | Cameroon | 'Cameroon' | | | Canada | 'Canada' | | | CapeVerde | 'Cape Verde' | | | CaymanIslands | 'Cayman Islands' | | | CentralAfricanRepublic | 'Central African Republic' | | | Chad | 'Chad' | | | Chile | 'Chile' | | | China | 'China' | | | ChristmasIsland | 'Christmas Island' | | | CocosKeelingIslands | 'Cocos (Keeling) Islands' | | | Colombia | 'Colombia' | | | Comoros | 'Comoros' | | | CongoDemocraticRepublicOfKinshasa | 'Congo (Democratic Republic of - Kinshasa)' | | | CongoRepublicOfBrazzaville | 'Congo (Republic of - Brazzaville)' | | | CookIslands | 'Cook Islands' | | | CostaRica | 'Costa Rica' | | | Croatia | 'Croatia' | | | Cuba | 'Cuba' | | | Curacao | 'Curaçao' | | | Cyprus | 'Cyprus' | | | CzechRepublic | 'Czechia / Czech Republic' | | | Denmark | 'Denmark' | | | Djibouti | 'Djibouti' | | | Dominica | 'Dominica' | | | DominicanRepublic | 'Dominican Republic' | | | EastTimor | 'East Timor' | | | Ecuador | 'Ecuador' | | | Egypt | 'Egypt' | | | ElSalvador | 'El Salvador' | | | EquatorialGuinea | 'Equatorial Guinea' | | | Eritrea | 'Eritrea' | | | Estonia | 'Estonia' | | | Ethiopia | 'Ethiopia' | | | FalklandIslands | 'Falkland Islands' | | | FaroeIslands | 'Faeroe Islands / Faroe Islands' | | | Fiji | 'Fiji' | | | Finland | 'Finland' | | | France | 'France' | | | FrenchGuiana | 'French Guiana' | | | FrenchPolynesia | 'French Polynesia' | | | FrenchSouthernTerritories | 'French Southern Territories' | | | Gabon | 'Gabon' | | | Gambia | 'Gambia' | | | Georgia | 'Georgia' | | | Germany | 'Germany' | | | Ghana | 'Ghana' | | | Gibraltar | 'Gibraltar' | | | Greece | 'Greece' | | | Greenland | 'Greenland' | | | Grenada | 'Grenada' | | | Guadeloupe | 'Guadeloupe' | | | Guam | 'Guam' | | | Guatemala | 'Guatemala' | | | Guernsey | 'Guernsey' | | | Guinea | 'Guinea' | | | GuineaBissau | 'Guinea-Bissau' | | | Guyana | 'Guyana' | | | Haiti | 'Haiti' | | | HeardAndMcDonaldIslands | 'Heard and McDonald Islands' | | | HolySee | 'Holy See' | | | Honduras | 'Honduras' | | | HongKong | 'Hong Kong' | | | Hungary | 'Hungary' | | | Iceland | 'Iceland' | | | India | 'India' | | | Indonesia | 'Indonesia' | | | Iran | 'Iran' | | | Iraq | 'Iraq' | | | Ireland | 'Ireland' | | | IsleOfMan | 'Isle of Man' | | | Israel | 'Israel' | | | Italy | 'Italy' | | | IvoryCoast | 'Ivory Coast' | | | Jamaica | 'Jamaica' | | | Japan | 'Japan' | | | Jersey | 'Jersey' | | | Jordan | 'Jordan' | | | KazakhstanNewCode | 'Kazakhstan New code' | | | KazakhstanOldCode | 'Kazakhstan Old code' | | | Kenya | 'Kenya' | | | Kiribati | 'Kiribati' | | | Kosovo | 'Kosovo' | | | Kuwait | 'Kuwait' | | | Kyrgyzstan | 'Kyrgyzstan' | | | Laos | 'Laos' | | | Latvia | 'Latvia' | | | Lebanon | 'Lebanon' | | | Lesotho | 'Lesotho' | | | Liberia | 'Liberia' | | | Libya | 'Libya' | | | Liechtenstein | 'Liechtenstein' | | | Lithuania | 'Lithuania' | | | Luxembourg | 'Luxembourg' | | | Macao | 'Macao' | | | Madagascar | 'Madagascar' | | | Malawi | 'Malawi' | | | Malaysia | 'Malaysia' | | | Maldives | 'Maldives' | | | Mali | 'Mali' | | | Malta | 'Malta' | | | MarshallIslands | 'Marshall Islands' | | | Martinique | 'Martinique' | | | Mauritania | 'Mauritania' | | | Mauritius | 'Mauritius' | | | Mayotte | 'Mayotte' | | | Mexico | 'Mexico' | | | Micronesia | 'Micronesia' | | | Moldova | 'Moldova' | | | Monaco | 'Monaco' | | | Mongolia | 'Mongolia' | | | Montenegro | 'Montenegro' | | | Montserrat | 'Montserrat' | | | Morocco | 'Morocco' | | | Mozambique | 'Mozambique' | | | Myanmar | 'Myanmar' | | | Namibia | 'Namibia' | | | Nauru | 'Nauru' | | | Nepal | 'Nepal' | | | Netherlands | 'Netherlands' | | | NewCaledonia | 'New Caledonia' | | | NewZealand | 'New Zealand' | | | Nicaragua | 'Nicaragua' | | | Niger | 'Niger' | | | Nigeria | 'Nigeria' | | | Niue | 'Niue' | | | NorfolkIsland | 'Norfolk Island' | | | NorthKorea | 'North Korea' | | | NorthMacedonia | 'North Macedonia' | | | NorthernCyprus | 'Northern Cyprus' | | | NorthernMarianaIslands | 'Northern Mariana Islands' | | | Norway | 'Norway' | | | Oman | 'Oman' | | | Pakistan | 'Pakistan' | | | Palau | 'Palau' | | | PalestinianAuthority | 'Palestinian Authority' | | | Panama | 'Panama' | | | PapuaNewGuinea | 'Papua New Guinea' | | | Paraguay | 'Paraguay' | | | Peru | 'Peru' | | | Philippines | 'Philippines' | | | PitcairnIslands | 'Pitcairn Islands' | | | Poland | 'Poland' | | | Portugal | 'Portugal' | | | PuertoRico | 'Puerto Rico' | | | Qatar | 'Qatar' | | | Reunion | 'Reunion' | | | Romania | 'Romania' | | | Russia | 'Russia' | | | Rwanda | 'Rwanda' | | | Saba | 'Saba' | | | SaintBarthelemy | 'Saint-Barthélemy' | | | SaintHelena | 'Saint Helena' | | | SaintKittsAndNevis | 'Saint Kitts and Nevis' | | | SaintLucia | 'Saint Lucia' | | | SaintMartin | 'Saint-Martin' | | | SaintPierreAndMiquelon | 'Saint Pierre and Miquelon' | | | SaintVincentAndTheGrenadines | 'Saint Vincent and the Grenadines' | | | Samoa | 'Samoa' | | | SanMarino | 'San Marino' | | | SaoTomeAndPrincipe | 'Sao Tome and Principe' | | | SaudiArabia | 'Saudi Arabia' | | | Senegal | 'Senegal' | | | Serbia | 'Serbia (PAK)' | | | SerbiaOldSystem | 'Serbia (old system)' | | | Seychelles | 'Seychelles' | | | SierraLeone | 'Sierra Leone' | | | Singapore | 'Singapore' | | | SintEustatius | 'Sint Eustatius' | | | SintMaarten | 'Sint Maarten' | | | Slovakia | 'Slovakia' | | | Slovenia | 'Slovenia' | | | SolomonIslands | 'Solomon Islands' | | | Somalia | 'Somalia' | | | SouthAfrica | 'South Africa' | | | SouthGeorgiaAndTheSouthSandwichIslands | 'South Georgia and the South Sandwich Islands' | | | SouthKorea | 'South Korea' | | | SouthSudan | 'South Sudan' | | | Spain | 'Spain' | | | SriLanka | 'Sri Lanka' | | | Sudan | 'Sudan' | | | Suriname | 'Suriname' | | | SvalbardAndJanMayenIslands | 'Svalbard and Jan Mayen Islands' | | | Swaziland | 'Swaziland' | | | Sweden | 'Sweden' | | | Switzerland | 'Switzerland' | | | Syria | 'Syria' | | | Taiwan | 'Taiwan' | | | Tajikistan | 'Tajikistan' | | | Tanzania | 'Tanzania' | | | Thailand | 'Thailand' | | | Togo | 'Togo' | | | Tokelau | 'Tokelau' | | | Tonga | 'Tonga' | | | TrinidadAndTobago | 'Trinidad and Tobago' | | | Tunisia | 'Tunisia' | | | Turkey | 'Turkey' | | | Turkmenistan | 'Turkmenistan' | | | TurksAndCaicosIslands | 'Turks and Caicos Islands' | | | Tuvalu | 'Tuvalu' | | | Uganda | 'Uganda' | | | Ukraine | 'Ukraine' | | | UnitedArabEmirates | 'United Arab Emirates' | | | UnitedKingdom | 'United Kingdom' | | | UnitedStatesMinorOutlyingIslands | 'United States Minor Outlying Islands' | | | UnitedStatesOfAmerica | 'United States of America' | | | UnitedStatesVirginIslands | 'United States Virgin Islands' | | | Uruguay | 'Uruguay' | | | Uzbekistan | 'Uzbekistan' | | | Vanuatu | 'Vanuatu' | | | Venezuela | 'Venezuela' | | | Vietnam | 'Vietnam' | | | WallisAndFutuna | 'Wallis and Futuna' | | | WesternSahara | 'Western Sahara' | | | Yemen | 'Yemen' | | | Zambia | 'Zambia' | | | Zimbabwe | 'Zimbabwe' | |