Skip to content

Instantly share code, notes, and snippets.

@brunoluiz
Created August 24, 2017 03:47
Show Gist options
  • Save brunoluiz/c10f1f521b5ac68297a9a3846c397128 to your computer and use it in GitHub Desktop.
Save brunoluiz/c10f1f521b5ac68297a9a3846c397128 to your computer and use it in GitHub Desktop.
const Joi = require('joi')
const ukzip = /^[A-Z]{1,2}[0-9]{1,2}[A-Z]{0,1} ?[0-9][A-Z]{2}$/i
module.exports = Joi.extend({
name: 'number',
base: Joi.number().strict()
}, {
name: 'zipcode',
base: Joi.regex(ukzip).description('UK Zipcode')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment