Skip to main content

isValidRgba

The isValidRgba function checks if the provided RGBA color string is valid.

Syntax

isValidRgba(color: string): boolean

Parameters

  • color (string): The RGBA color string to validate.

Returns

  • boolean: True if the color string is valid, false otherwise.

Example

import { isValidRgba } from 'colore-js';

console.log(isValidRgba('rgba(255, 0, 0, 1)')); // Output: true
console.log(isValidRgba('rgba(100%, 0%, 0%, 0.5)')); // Output: true
console.log(isValidRgba('rgba(255, 255, 256, 1)')); // Output: false
console.log(isValidRgba('rgba(300, 0, 0, 0)')); // Output: false

Usage

The isValidRgba function is used to validate whether a given color string conforms to the RGBA color format. This can be useful for input validation in color manipulation and design applications.