UNPKG

@simongrasinovski/str-utils

Version:

A lightweight utility library for effortless string manipulation. Simplify common tasks like case validation, conversion and formatting with easy-to-use functions that enhance your JavaScript applications

23 lines (21 loc) 612 B
"use strict"; var _require = require('./utils'), ensureString = _require.ensureString; var _require2 = require('./constants'), HEX_COLOR_REGEX = _require2.HEX_COLOR_REGEX; /** * Checks if a string is a valid HEX color. * * @function * @param {string} input - The string to valiate. * @returns {boolean} true if valid, false otherwise. * * @throws {TypeError} Throws an error if the input is not a string. * * @example * const result = isValidHex('#ff5733'); * console.log(result); // true */ module.exports = ensureString(function (input) { return HEX_COLOR_REGEX.test(input); });