IsValid - CFMX 7 Little Things

February 10, 2005

ColdFusion MX 7 added a new function called IsValid. The IsValid function performs data validation just like the CFPARAM tag, and supports all the new data types in cfparam (see my previous post) as well.

For instance if we want to validate the a variable has an integer value:

<cfif IsValid("integer", url.value)>
	Valid integer!
	Invalid Integer!

For a range:

<cfif IsValid("range", url.value, 1, 100)>
	Value is between 1 and 100
	Value is not between 1 and 100

And for regular expressions:

<cfif IsValid("regex", url.value, "[A-Z][a-z]+")>
	Word starts with a capital letter
	Word does not match pattern.

Related Entries

3 people found this page useful, what do you think?


Hmm - according to the docs - the regex is a JS regex, not a CF regex. Anyone know why?
According to Ray's post on his blog, it does infact use CF Regex.
CF and JS regexen are both POSIX, no? And neither support the single most useful (and simplest to implement) Perl extension though - lazy matching. Either way, that regexp wants a leading "^"...

Post a Comment


Spell Checker by Foundeo

Recent Entries


did you hack my cf?