<cfparam>
Tests for a parameter's existence, tests its data type, and provides a default value if one is not assigned.
This tag may have a body.
This tag is also supported within <cfscript>
<cfparam
name=string
type=string
default=any
min=number
max=number
pattern=string
maxLength=int
><!--- body --->[</cfparam>]
| Attribute | Description |
|---|---|
name
string, required
|
edit
The name of the parameter to test, such as Client.Email or Cookie.BackgroundColor. If you omit the DEFAULT attribute, an error occurs if the specified parameter does not exist |
type
string, optional
|
edit
The type of parameter that is required. The default is 'any' and valid values are:
|
default
any, optional
|
edit
Default value to set the parameter to if it does not exist. |
min
number, optional
|
edit
define the smallest size of a numeric value, used for type range |
max
number, optional
|
edit
define the biggest size of a numeric value, used for type range |
pattern
string, optional
|
edit
define a regular expression pattern, to check value against |
maxLength
int, optional
|
edit
define the maxlength of a value for this types: email, url and string |
Examples
editSimple Example
Tag example
<cfparam name="FORM.test" default="1">
<cfif FORM.test EQ '1'>
<cfset isError = false>
<cfelse>
<cfset isError = true>
</cfif>
<cfoutput>#isError#</cfoutput>
Script example
param name="FORM.test" default="1";
if(FORM.test EQ '1') {
isError = false;
}
else {
isError = true;
}
writeoutput("#isError#")
See also
- Core CFML Language
- <cfset>
- Data Types in Lucee
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)