Skip to main content
Inspiring
August 11, 2010
Answered

IsValid and cfparam acceppting lists of values instead of values?

  • August 11, 2010
  • 3 replies
  • 1882 views

Hello,

I've noticed that cfparam and IsValid accepts a list of integers as a valid value when type="integer" is specified. Is this a bug, or the expected behavior?

Example:

I have a code like this on my pages to check the values passed,

<cftry>
    <cfparam name="url.n" default="1" type="integer">
<cfcatch>
    <cflocation url="error.cfm" addtoken="no">
</cfcatch>
</cftry>

And also tried:

<cfif NOT IsDefined("url.n") OR NOT IsValid("integer",url.n)><cflocation url="error.cfm" addtoken="no"></cfif>

In both cases, if I pass an url value like n=4 or n=string, it works as expected. With n=4, n passes the check, and the rest of the page is executed. With n=string, a string is detected and a redirection to error.cfm is called.

But, if I pass an url value like n=4,14 then n passes the checks and the rest of the page is executed...  ???

Using CF 8.01 over CentOS.

    This topic has been closed for replies.
    Correct answer Ernesto RA

    I've have found this old thread while cleaning my mail... just a fast update: never received a bug id, but on ColdFusion 2016 the issue seems to have been solved (I suppose it was on an earlier version, but CF2016 is where I have just checked) and <cfdump var="#isValid('integer','1,2,3')#"> returns NO, as expected.

    3 replies

    Ernesto RAAuthorCorrect answer
    Inspiring
    September 13, 2017

    I've have found this old thread while cleaning my mail... just a fast update: never received a bug id, but on ColdFusion 2016 the issue seems to have been solved (I suppose it was on an earlier version, but CF2016 is where I have just checked) and <cfdump var="#isValid('integer','1,2,3')#"> returns NO, as expected.

    EddieLotter
    Inspiring
    September 13, 2017

    Thanks for reporting back.

    Please mark your post as the answer to close this thread.

    Cheers

    Eddie

    Inspiring
    September 13, 2017

    Hi Eddie, I can find no 'Correct' option anywhere on my last post,,,    Also, there is not "This question is Not Answered" on my original post. Perhaps the thread is too old to have that features active?

    Inspiring
    August 11, 2010

    Dan, Adam, thanks for your replies.

    I also was so surprised that I was afraid that it was a "feature", not an error. I've submited a bug report form, I'll post the ID if accepted.

    Thanks, best wishes,

    Participant
    October 19, 2010

    Helllo,

    actually I got the same problem and try to find out if this is a bug or a feature.

    If this is a bug, is a bug id available.

    I found no bug with isvalid and integer in the bugtracker(http://cfbugs.adobe.com)

    My investigations has the following results.

    - In CF6 it is false

    - <cfparam name="list" type="integer"> also returns true

    - 3,1,5 is also an integer and int(3,1,5) give a cfusion time value38412 (01.03.2005[DD.MM.YYYY])

    at first I thought CF9 switch the list into a datetimevalue and this is an integer, but the list 3,5,7,12,456,222,.... is also an integer.

    This is a big problem for websites, that check a url variable for integer.

    All of my <cfparam type="integer" name="url.number"> does not work anymore.

    Thanks for the help

    AA

    Inspiring
    August 11, 2010

    This

    <cfdump var="#isValid('integer','1,2,3')#">

    give me YES.

    To me, that's an unexpected result.  Also, the docs don't mention anything about this.  I recommend that you submit a bug report.

    Inspiring
    August 11, 2010

    Agreed.

    I was somewhat surprised that CF can't do this fairly fundamental sort of validation correctly.

    If you raise the issue & let us know the URL / bug ID, I'll go vote for it.

    --

    Adam