loading...

ColdFusion isDomain() UDF

gamesover profile image James Moberg ・2 min read

Since Apility.io introduced a new "free" tier on 12/1/2019 that provides 40k API hits per month, I've decided to revisit and add support to my ColdFusion web application framework in order to better combat feedback form spam. I recently wrote a CFC, CFTag & API endpoint for CleanTalk, so adding support for Apility shouldn't be too difficult. Apility uses multiple sources and can test IP, email and domain names as well as return other data like WHOIS & geolocation.

In preparation for this, I wanted to make it so the function auto-detects what is being tested (IP, email or domain name), automatically performs the correct API call and returns the standardized pass/fail response.

ColdFusion has a built-in isValid() function that supports email, but there's no support for IP or domain name. CFLib provides an isIP() UDF and also has an isURL() UDF. The isEmail() UDF is very basic and Adobe's built-in isValid("email") is/was buggy. As a result, I prefer to use my own UDFs versus blindly trusting that Adobe won't change something or introduce a new version-specific bug. (For email, I use Dominic Sayer's isEmail Java library. This library is awesome & also performs an optional MX record test.)

I noticed that there wasn't anything available to test whether a string is a validly formatted domain name, so I thought I'd come up with something.

Alt Text

Enjoy!

Check it out on TryCF.com.

Discussion

pic
Editor guide