Alex Rivera | Logout

Why isvalid("integer","1,5") = YES?

Asked 2012-07-18T07:06:49.220
12

Why does #isValid("integer","1,5")# output YES? I expected it to output NO like #isValid("integer","1.5")# does.

I'm going to validate with <CFIF isvalid("integer","1,5") AND isnumeric("1,5")> ...

Edit
Report

1 Answer

10

If you want to make absolutely sure you have an Integer, you could use Java Integer methods.

<cfscript>
createObject("java","java.lang.Integer").parseInt("1,5");
</cfscript>

The parseInt() method throws when it is given anything that cannot be interpreted as an Integer. This includes "1,5".

answered 2012-07-18T10:32:26.087

Your Answer