UNPKG

joi-postcode

Version:

Postcode validation via regex for Joi

16 lines (10 loc) 583 B
# joi-postcode Validate UK postcodes with Joi. This is a regex based validation taken from the excellent [postcode.js](https://github.com/ideal-postcodes/postcode.js). Note that this will just check the format of the given string is correct, not that the postcode exists. See [note on postcode validation](https://github.com/ideal-postcodes/postcode.js/blob/master/README.md#note-on-postcode-validation). ## Usage ```js var Joi = require('joi').extend(require('joi-postcode')) Joi.postcode().validate('WC2N 4HG', function (err) { console.log(err ? 'Invalid' : 'Valid') }) ```