1.0.1 • Published 5 years ago

joi-color v1.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

joi-color

Extension to validate colors with Joi

It validates #rgba format.

Positive examples:

Usage

Use it as a joi extension. Example:

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:

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

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