isValidHsla
The isValidHsla
function checks if the input string is a valid HSLA color format.
Syntax
isValidHsla(color: string): boolean
Parameters
color
(string): The input color string.
Returns
- boolean: True if the input is a valid HSLA color, false otherwise.
Example
import { isValidHsla } from 'colore-js';
console.log(isValidHsla('hsla(120, 100%, 50%, 0.5)')); // Output: true
console.log(isValidHsla('hsla(120, 100%, 50, 0.5)')); // Output: false
console.log(isValidHsla('hsla(400, 100%, 50%, 0.5)')); // Output: false
console.log(isValidHsla('hsla(120, 100%, 50%, 1.5)')); // Output: false
Usage
The isValidHsla
function is used to validate whether a given color string conforms to the HSLA color format. This can be useful for input validation in color manipulation and design applications.