New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

postcode-validator

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcode-validator

Validate postcodes based on country

latest
Source
npmnpm
Version
3.10.15
Version published
Weekly downloads
203K
-20.49%
Maintainers
1
Weekly downloads
 
Created
Source

postcode-validator

Commitizen friendly

Node.js module for parsing and validating postcodes. Country specific validation is supported for most countries including GB, US, Canada, Japan and many others.

Note: I haven't tested all combinations of postcodes for the extended country regular expressions. Please raise a PR with necessary test coverage for as many countries possible.

Install

npm install postcode-validator

Usage

// commonjs
const { postcodeValidator, postcodeValidatorExistsForCountry } = require('postcode-validator');
// ES6
import { postcodeValidator, postcodeValidatorExistsForCountry } from 'postcode-validator';

postcodeValidator('W85TT', 'GB'); // returns true
postcodeValidator('1234567', 'GB'); // returns false

postcodeValidatorExistsForCountry('GB'); // returns true
postcodeValidatorExistsForCountry('Moon'); // returns false

country codes: US, GB, CA, JP, INTL(International), etc

Testing

Run the unit tests with:

npm test

Conventional Commits

Commit code using below npm script or just follow conventional commits for commit messages using git commit.

npm run commit

Keywords

postcode

FAQs

Package last updated on 28 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts