isValidHexString ColdFusion UDF
James Moberg

James Moberg @gamesover

About: I’m a ColdFusion/CFML web application developer at SunStar Media located in Monterey, CA. I am a fan of technology, music and web development.

Location:
Monterey, CA
Joined:
Aug 18, 2017

isValidHexString ColdFusion UDF

Publish Date: Mar 7 '25
0 0

While working on my ColdFusion colorTools CFC, I wondered if isValid() supported a "hex" type since "guid" & "UUID" both rely on validating hexadecimal numbers... and the answer is no.

NOTE: I've added some new features to colorTools, but will write about them next week after I add some demo & test scripts.

Validating hex strings isn't difficult, but some values may be prefixed with "#" or "0x". Hex is also used for many other things beyond color codes, but I wanted to optionally & explicitly test for 6 character string values when accepting hex color values. I believe that this UDF covers all the requirements. (If it doesn't, let me know.)

Source Code

https://gist.github.com/JamoCA/c4079d7c813b0ad3d1a28cfc7551c355

Comments 0 total

    Add comment