Package Exports
- joi-postalcode
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 (joi-postalcode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
joi-postalcode
Joi extension for validating postal codes worldwide using postal-codes-js.
Versions
- Version 1.X is for Joi < v14
- Version 2.X (latest) is for Joi > v14
How to Use
Get the required packages:
npm install joi joi-postalcodeCreate an extended instance of Joi, then specify the 2-letter
ISO country code as a parameter to postalCode in your schema:
const Joi = require('joi')
const joiPostalCode = Joi.extend(require('joi-postalcode'))
joiPostalCode.string().postalCode('CA').validate('A1A 1A1') // Canada
joiPostalCode.string().postalCode('').validate('90210') // Default country is US
joiPostalCode.string().postalCode('TR').validate('33150') // TurkeySee List of postal codes for a list of postal code formats and supported countries.