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!
<cfelse>
Invalid Integer!
</cfif>
For a range:
<cfif IsValid("range", url.value, 1, 100)>
Value is between 1 and 100
<cfelse>
Value is not between 1 and 100
</cfif>
And for regular expressions:
<cfif IsValid("regex", url.value, "[A-Z][a-z]+")>
Word starts with a capital letter
<cfelse>
Word does not match pattern.
</cfif>
Tweet
Related Entries
- Top 10 Underrated Functions in ColdFusion - January 10, 2007
- CFFUNCTION and CFARGUMENT don't support new types in ColdFusion 7 - April 13, 2005
- Hash - March 15, 2005
- Strong Encryption Technote shows undocumented features - February 22, 2005
- CFTIMER - Little things in ColdFusion 7 - February 11, 2005
Trackbacks
Trackback Address: 224/ACA0392FEB1416965B4D08FE6A231303
Comments
On 02/10/2005 at 11:35:42 PM EST Raymond Camden wrote:
1
Hmm - according to the docs - the regex is a JS regex, not a CF regex. Anyone know why?
On 02/11/2005 at 7:30:05 PM EST Pete Freitag wrote:
2
According to Ray's post on his blog, it does infact use CF Regex.
http://ray.camdenfamily.com/index.cfm?mode=entry&entry=02586859-DBB8-5F75-494E8BC257561C56
On 02/13/2005 at 12:16:18 PM EST Pete Jordan wrote:
3
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
Recent Entries
- Nginx redirect www to non www domain
- HashDOS and ColdFusion
- HackMyCF Updated for APSB11-29 Security Hotfix
- Adobe eSeminar on FuseGuard
- Determining Which Cumulative Hotfixes are Installed on ColdFusion
- Adding Two Factor Authentication to ColdFusion Administrator
- ColdFusion Developer Week at Adobe.com
- Bug Loading Scripts for CFFileUpload and CFMediaPlayer


add to del.icio.us



