Package Exports
- postcode-validator
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcode-validator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
postcode-validator
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-validatorUsage
// 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), etcTesting
Run the unit tests with:
npm testConventional Commits
Commit code using below npm script or just follow conventional commits for commit messages using git commit.
npm run commit