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

val-zip

v1.0.13

Published

Validate zip codes fast and accurate! A Library of JavaScript Regular Expressions for validating if a specific zip code actually exists in a specific Country.

Downloads

135

Readme

Validate ZIP Codes with Regular Expressions

npm Featured on Openbase

A Library of JavaScript Regular Expressions for validating if a specific Zip-code exists in a specific Country.

Not every 5 digit number is automatically a zip code... As of now Regular Expression seem to be the fastest way of validating if a zip code actually exists. No slow backend validation needed, just some fancy RegExp.

So Why val-zip? Because it is free for commercial use and it is super fast and light weight with only 448kB size.

img

As of now the Regular Expressions for Germany, Austria, Switzerland, USA (5-Digit version), Belgium, Denmark, Czechia, Finland, Norway, Italy, Spain, Estonia, Iceland, France, Luxembourg are available with more coming asap.

Usage

Download via Node Package Manager (NPM):

npm install val-zip

Import via Content Delivery Network (CDN):

<script type="module" src="https://cdn.skypack.dev/val-zip@latest" corossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/val-zip@latest/dist/val-zip.umd.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module" src="https://unpkg.com/[email protected]/dist/va-zip.udm.js" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Note: CDN is still wip, so error may occur. In doubt use skypack cdn

Example

import valZip from "val-zip"; // make sure to use type="module" or the ".mjs" file extension
// alternative: const valZip = require("val-zip"); 
// note: the require function is nodejs specific and is not available in a ESM or Browser environment.
// make sure to use type="commonjs" or the ".cjs" file extension

// let's say a random user puts in a zipcode somehow and you want to validate if the zip code exists.

var userCountry = "US"; //  ISO 3166 Country Code; string
var inputZip_1 = "12345"; // fake, this zipcode does NOT exist in the United States 
var inputZip_2 = "00601"; // reak, exists


valZip(inputZip_1, userCountry) // returns false
valZip(inputZip_2, userCountry) // returns true

Zip Code Sources

Note: All data is heavily modified and does not resemble the original data base at all

| country | last update | license | source | | ------------- | ----------- | :---------------------------------------------------------: | ---------------------------------------------------------------------- | | Austria | 04.01.2023 | none | Österreichische Post Aktiengesellschaft | | Belgium | 21.11.2021 | none | Bpost | | Switzerland | 01.01.2023 | CC-BY | Die Schweizerische Post | | Czechia | 01.01.2023 | none | Česká pošta | | Germany | 01.06.2019 | none | Launix | | Denmark | 22.06.2022 | none | PostNord Danmark | | United States | 31.12.2020 | none | Internal Revenue Service, US Census | | Norway | 01.10.2022 | none | Osten Norge AS | | Finland | 30.01.2023 | none | Posti Group Oy | | Italy | 26.11.2020 | Eurostat free re-use of data | Eurostat | | Spain | 26.11.2020 | Eurostat free re-use of data | Eurostat | | Estonia | 05.02.2023 | none | Republic of Estonia | | Iceland | 06.02.2023 | none | Íslandspóstur | | France | 06.02.2023 | Open License v2.0 | La Poste Groupe | | Luxembourg | 06.02.2023 | CC-0 | Portail Open Data |

Some Countries are missing, just because the official zipcode database is either paywalled or entirely copyrighted.

This is the List of countries I am unable to source data from:

| country | limitation | source | | --------- | ---------------- | ------------------------------ | | Poland | only with permit | Poczta Polska Spółka Akcyjna | | Sweden | paid only | Postnummerservice Norden AB | | Australia | paid only | Australia Post |

MIT License Copyright (c) 2022-today Leonhard Maier