the-simplifier
  • 💚Welcome!
  • 📦Installing
  • Functions
    • The Simplifier Functions
  • 🎫Validators
    • 🟢isWebsiteUp
    • #️⃣ isValidHexColor
  • 🎡Converters
    • ⏱️convertTime
    • 🔵convertColors
  • 📔Formatters
    • 🔢NumberFormatter
  • 📸OCR
    • 📑📷 readImage
  • ❌Fakes
    • 🧪createFakeUser
  • 🔅Modified native functions
    • 📜Map
  • 🌐No category
    • 🔃getRandomFromArray
    • 🔠generateChars
    • 🔄getRandomInt
Powered by GitBook
On this page

Was this helpful?

  1. Validators

#️⃣ isValidHexColor

Verify if the function input is a valid hex color

validateHexColor.js
import { isValidHexColor } from 'the-simplifier'

let verifyHex = () => {
    let color = '#foo'
    
    if(!isValidHexColor(color)) {
        return console.log('Invalid hex provided')
    } else {
        return console.log('Valid hex provided')
    }
}

verifyHex() // Expected: Invalid hex provided

The color provided must be a string and started with "#"

PreviousisWebsiteUpNextConverters

Last updated 4 years ago

Was this helpful?

🎫