joi-postcode

Postcode validation via regex for Joi

Usage no npm install needed!

<script type="module">
  import joiPostcode from 'https://cdn.skypack.dev/joi-postcode';
</script>

README

joi-postcode

Validate UK postcodes with Joi.

This is a regex based validation taken from the excellent 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.

Usage

var Joi = require('joi').extend(require('joi-postcode'))

Joi.postcode().validate('WC2N 4HG', function (err) {
  console.log(err ? 'Invalid' : 'Valid')
})