Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hugomd/joi-currency-code

💰 Joi validation for ISO 4217 currency codes.
https://github.com/hugomd/joi-currency-code

custom extension joi plugin validation

Last synced: 3 months ago
JSON representation

💰 Joi validation for ISO 4217 currency codes.

Awesome Lists containing this project

README

        

# 💰 joi-currency-code

[![npm](https://img.shields.io/npm/v/joi-currency-code.svg?maxAge=2592000)](https://www.npmjs.com/package/joi-currency-code) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

> A Joi validator that validates whether a given input is a valid currency code, according to ISO 4217.

## Installation

```javascript
npm install joi-currency-code
```

## Usage

```javascript
const Joi = require('joi').extend(require('joi-currency-code'));

const schema = Joi.object({
code: Joi.string().currency()
});

Joi.validate({
code: 'aud'
}, schema); // succeeds

Joi.validate({
code: 'fake-currency'
}, schema); // fails with ValidationError
```

## Contributing

* `git clone [email protected]:hugomd/joi-currency-code.git`
* `npm install`
* Make your changes
* Open a pull request and ask for review ✌️
* Optional: use emoji in your commits 🔥

## Related Repositories

* [`is-currency`](https://github.com/hugomd/is-currency)
* [`is-currency-code`](https://github.com/hugomd/is-currency-code)
* [`is-currency-symbol`](https://github.com/hugomd/is-currency-symbol)