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: 2 months ago
JSON representation
💰 Joi validation for ISO 4217 currency codes.
- Host: GitHub
- URL: https://github.com/hugomd/joi-currency-code
- Owner: hugomd
- Created: 2017-06-06T00:57:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T19:16:25.000Z (11 months ago)
- Last Synced: 2025-04-19T12:10:07.021Z (3 months ago)
- Topics: custom, extension, joi, plugin, validation
- Language: JavaScript
- Homepage:
- Size: 461 KB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 💰 joi-currency-code
[](https://www.npmjs.com/package/joi-currency-code) [](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); // succeedsJoi.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)