1.0.1 • Published 7 years ago

valid-web-color v1.0.1

Weekly downloads
72
License
MIT
Repository
github
Last release
7 years ago

Valid Web Color

A simple utility function returning a boolean for whether or not a string is a valid web color

NPM

Example

import validWebColor from 'valid-web-color';

console.log(validWebColor('#fff')); // true, short hex
console.log(validWebColor('#ffffff')); // true, long hex
console.log(validWebColor('white')); // true, named color
console.log(validWebColor('rgb(255,255,255)')); // true, RedGreenBlue
console.log(validWebColor('rgba(255,255,255, 1)')); // true, RedGreenBlueAlpha
console.log(validWebColor('hsl(0, 0%,100%)')); // true, HueSaturationLightness
console.log(validWebColor('hsla(0, 0%, 100%, 1)')); // true, HueSaturationLightnessAlpha

console.log(validWebColor('#sagdfhdfjd')); // false, random invalid string
console.log(validWebColor({})); // false, non-string

License

MIT