postcode-validator
TypeScript icon, indicating that this package has built-in type declarations

3.10.1 • Public • Published

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.10.143,029latest

Version History

VersionDownloads (Last 7 Days)Published
3.10.143,029
3.10.02
3.9.28,353
3.9.11
3.9.01
3.8.217,631
3.8.2013,866
3.8.190
3.8.180
3.8.171
3.8.160
3.8.1595
3.8.14711
3.8.130
3.8.12705
3.8.11129
3.8.100
3.8.91
3.8.80
3.8.70
3.8.61,605
3.8.50
3.8.40
3.8.30
3.8.20
3.8.10
3.8.04,522
3.7.04,326
3.6.6564
3.6.50
3.6.00
3.5.33,424
3.5.20
3.5.00
3.4.20
3.3.10
3.3.067
3.2.158
3.2.01,047
3.1.133
3.1.02,374
3.0.087
2.1.052
2.0.034
1.2.14,749
1.2.049
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.00
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.21
1.0.10
1.0.00

Package Sidebar

Install

npm i postcode-validator

Weekly Downloads

97,517

Version

3.10.1

License

MIT

Unpacked Size

41.8 kB

Total Files

15

Last publish

Collaborators

  • melwynfurtado