Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

validate-css-value

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

validate-css-value

Validate whether a CSS value is valid for a given property using real browser checks.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

validate-css-value

Validate whether a CSS value is valid for a given property using real browser checks.

Given that it depends on browser-side checks it can be assumed to not work as expected outside of a browser (e.g. Node).

Installation

With npm:

npm install validate-css-value

With yarn:

yarn add validate-css-value

Examples

import { validate } from 'validate-css-value';

// With kebab-case.
validate('background-color', 'red'); // => true
validate('background-color', 'rud'); // => false

// With camelCase.
validate('backgroundColor', 'red'); // => true
validate('backgroundColor', 'rud'); // => false

// Supports more than just colors, including shorthand values.
validate('border', '1px solid red');       // => true
validate('border', '-1px occasional rud'); // => false

Testing

cypress is used for testing. yarn test will likely work in a development environment, but may require some additional configuration in CI.

Credit

Inspired by this StackOverflow question and its answers.

FAQs

Package last updated on 14 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc