# joi-color

> Extension to validate colors

Latest version **1.0.1** (published 2019-06-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install joi-color
pnpm add joi-color
yarn add joi-color
bun add joi-color
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-08 |
| First published | 2019-06-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nelsonfrancisco |

## Links

- npm: https://www.npmjs.com/package/joi-color
- Repository: https://github.com/NelsonFrancisco/joi-color
- Homepage: https://github.com/NelsonFrancisco/joi-color#readme
- Issues: https://github.com/NelsonFrancisco/joi-color/issues
- npm.io page: https://npm.io/package/joi-color

## Recent versions

- 1.0.1 (latest) — 2019-06-08

## README

# joi-color
Extension to validate colors with [Joi](https://github.com/hapijs/joi)

It validates #rgba format.

Positive examples:
 - #234
 - #223344
 - #223344ee
 - #234e

 Or even some common color names. Inspired in https://doc.qt.io/qt-5/qml-color.html
 
 For all the colors, please check `src/common-colors`

# Usage

 Use it as a joi extension. Example:
 
 ```javascript
 const joi = require('joi')
 const joiColor = require('joi-color')

 const is = joi.extend(joiColor(joi))
 (...)
 const schema = is.string().color()
 ```

# Options

A single option is provided. In color function, a boolean defines whether the validation returns a common color name, or its hexadecimal representation.
Example:

 ```javascript
const validated = await is.validate({
  color: 'red',
},{
  color: is.string().color(true)
})
 ```

 `(validated.color === #ff0000)` is true

---
_Source: https://npm.io/package/joi-color · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
