Was "Range" validation intended for non-numbers as well as numbers?
Here's why I ask:
I have a latitude property with a range rule between -90 and 90.
I learned yesterday that this value will pass this validation: "43 28.3"
Notice the space?
Now, try this in a scribble pad:
LT 180? #"43 28.3" LT 180#
<br>
LT 90? #"43 28.3" LT 90#
<br>
So what was happening on my form was that for latitude, that number
with a space was passed through as valid, and the same value for
longitude was being flagged as invalid.
yet "a" and "b" and "mcdonalds" all fail the range test (expectedly).
So I figured that the range validation was *intended* to be used only
for numeric validation, but thanks to CF's, uh, quirks, there are
cases where non-numbers can in fact fall within the ranges.
In my copy of VT, I modified the Range validator to do an isnumeric
check and fail if that doesn't pass
<cfif shouldTest(arguments.validation) AND
( NOT isNumeric(theValue) OR (theValue LT parameters.Min OR
theValue GT parameters.Max) )>
Should this be added to the VT?
Marc
P.S. If you want more ColdFusion fun, try this:
#lsIsDate('4/15/201717')#
<br>
#isDate('4/15/201717')#
<br>
#lsIsDate('4/15/20171')#
<br>
#isDate('4/15/20171')#
<br>
#isValid('date', "3.1458")# and #isDate('3.1458')# and #lsIsDate('3.1458')#
--
You received this message because you are subscribed to the Google Groups "ValidateThis-dev" group.
To post to this group, send email to validate...@googlegroups.com.
To unsubscribe from this group, send email to validatethis-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/validatethis-dev?hl=en.
I've been preferring to just write custom range validators when
necessary. So, "SRV_DateRange", for example.
I believe a validator should do one thing and do it well.
I've been preferring to just write custom range validators when
necessary. So, "SRV_DateRange", for example.
I believe a validator should do one thing and do it well.
> --
> You received this message because you are subscribed to the Google Groups
> "ValidateThis-dev" group.
> To post to this group, send email to validate...@googlegroups.com.
> To unsubscribe from this group, send email to
> validatethis-d...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/validatethis-dev?hl=en.
>
--
Bob Silverberg
www.silverwareconsulting.com