Update:
En fait il y a une nouvele fonction dans CF7 : isValid, qui permet le même mécanisme de validation que CFPARAM, en plus court à mon goût :)
<cfif not IsValid("integer", myVal)>Invalid Integer!</cfif>
OU
<cftry>
<cfparam name="myVal" default="" type="integer">
<cfcatch><cfoutput>Invalid Integer!</cfoutput></cfcatch>
</cftry>
types supportés par défaut (je cite):
- creditcard - After stripping blanks and dashes, a number that conforms to the mod10 algorithm. Number must have 13-16 digits.
- email- Valid address characters are a-zA-Z0-9_- and the period and separator. There must be a single at sign (@) and the text after the @
character must include a period. - eurodate - A date in the form d/m/y, d-m-y, or d.m.y. The m and d format can be 1 or 2 digits; y can be 2 or 4 digits. Converts the input to ODBC date format. Allows entry of a time part, but removes it from the ODBC value.
- float - same as numeric
- integer - An integer of the range -2,147,483,648 -- 2,147,483,647
- range - a
numeric
value between the values specified in themin
andmax
attribute. - regex - value must match the regular expression passed into the
pattern
attribute. - regular_expression - same as
regex
- ssn - A nine-digit Social Security number. Can be of the form xxx-xx-xxxx or xxx xx xxxx.
- social_security_number - same as
ssn
- time- A time. Can be in 12-hour or 24-hour clock format, and can include seconds in the form hh:mm:ss or a case-independent am or pm indicator.
Converts the input to ODBC time format. Allows entry of a date part,
but removes it from the ODBC value. - url - A valid URL. Must start with http:\\, https:\\, ftp:\\, file:\\, mailto:, or news:. Can include, as appropriate, username and password designators and query strings. The main part of the address can only have the characters A-Za-z0-9 and -.
- usdate - A date in the form m/d/y, m-d-y , or m.d.y, The m and d format can be 1 or 2 digits; y can be 2 or 4 digits. Does not convert the string to an ODBC value and does not allow a time part.
- zipcode - A 5-digit or 9-digit U.S. ZIP code. In 9-digit codes, the final four digits must be preceded by a hyphen (-) or space.