
Securing ColdFusion • Chapter 10 433
<CFABORT showerror="The variable ID has a value other than a
number">
</CFIF>
To combine this with a default value, refer to Figure 10.37.
Figure 10.37 CFIF and Functions Used in Place of a CFPARAM to
Validate Data and Set a Default
<CFIF NOT IsDefined('ID')>
<CFSET ID=0>
<CFELSEIF NOT IsNumeric(ID)>
<CFABORT showerror="The variable ID has a value other than a
number">
</CFIF>
All you have to do here is replace the not defined message with the
setting of the variable.This is five lines of code rather than one, but you
get to control the error messages and maybe do more checking.This
brings us to our final type of checking.