1.0.0 • Published 4 years ago

@pixul/joi-country v1.0.0

Weekly downloads
390
License
MIT
Repository
github
Last release
4 years ago

Joi Country

A Joi extension for validation of ISO 3166-1 alpha-2 country codes.

Installation

npm install --save @pixul/joi-country

Usage

const BaseJoi = require('@hapi/joi')
const JoiCountryExtension = require('@pixul/joi-country')
const Joi = BaseJoi.extend(JoiCountryExtension)

const schema = Joi.string().country()
const result = await schema.validate('gb')

console.log(result) // GB

Credits

This plugin is a fork & rewrite of https://github.com/Tallysticks/joi-country-extension to support joi > 16