IsValid and RegEx Issues
While writing some new documentation on ColdFusion MX 7 features you may have missed (for the soon to be released Fusion Authority Quarterly Update), I came across an interesting issue with the IsValid function.
This function is used to test if a ColdFusion variable is of a particular data type or if it is a particular value (email address, credit card, etc). In many ways this is a single function that can stand in for most of the standard "IS" functions (IsStruct, IsQuery, etc.) One noted exception is that the function has no existance checking (IsDefined).
One feature of the function is the ability to use a regular expression as a validator. This makes the IsValid tag a perfect replacement for using REFind to do regular expression pattern validation. That is, with a single exception. REFind is case sensitive and has a NoCase version to deal with non-case sensitive matches. IsValid is only case sensitive.
For many, this may mean that using IsValid in place of REFind for regular expression pattern validation is not an option. To those I say, there is a simple solution.
ColdFusion MX 7 has some advanced options for regular expressions which include a simple prefix for any expression to make it case insensitive. To make IsValid in regular expression mode case insensitive, just do the following:
The (?i) syntax at the start of a regular expression pattern makes the entire match case insensitive. Other advanced regular expression prefixes can be used with the function as well, which can greatly expand its capabilities.
Note that we are talking about the ColdFusion-style regular expressions here. The documentation for the IsValid function incorrectly states that it uses Javascript-style regular expression syntax. This is not the case.
There are a few other quirks with the function that you're almost never going to run into and I suggest you keep an eye on the IsValid LiveDocs entry for any changes and clarifications.

