Dependent Values

5 views
Skip to first unread message

santea

unread,
Jul 29, 2009, 5:08:15 PM7/29/09
to ValidateThis!
Not sure if I would call this a bug but, we ran into an issue today
where we were trying to validate a field (RoutingNumber) based on the
value of "Type" which is a drop down of payment types. If the type
were to equal "CHECK", then the rounting number field is required. So
this is how we first implemented the XML:

<property name="Type" desc="Payment Type">
<rule type="required" contexts="*" failureMessage="You must select
a Payment Type" />
</property>
<property name="RoutingNumber" desc="Check Routing Number">
<rule type="required" contexts="*" failureMessage="You must enter a
check routing number">
<param DependentPropertyName="Type" />
<param DependentPropertyValue="Check" />
</rule>
</property>

Immediately our unit testing began to fail with a message of "Variable
CHECK is undefined". After poking around ServerValidator.cfc, it
turns out that its trying to do:

<cfset theCondition = "get#v.Parameters.DependentPropertyName#() EQ
#v.Parameters.DependentPropertyValue#" />

which of course fails for non-numeric values. So to solve this
problem, all we did was place the DependentPropertyValue around single
quotes.

<param DependentPropertyValue="'Check'" />

That solved it, and everything is working now.

Bob Silverberg

unread,
Jul 29, 2009, 5:24:50 PM7/29/09
to valida...@googlegroups.com
Good catch! I guess I only tested it with a numeric value :-(

It seems like a simple fix would be to put the single quotes around
the expression in the ServerValidator.cfc, so:

<cfset theCondition = "get#v.Parameters.DependentPropertyName#() EQ
#v.Parameters.DependentPropertyValue#" />

becomes

<cfset theCondition = "get#v.Parameters.DependentPropertyName#() EQ
'#v.Parameters.DependentPropertyValue#'" />

That should still work with numeric values, and then your original
xml, without the single quotes, will work as well.

I'll roll that into the next release. If you feel like being really
helpful, you could try making that change to your own copy of
ServerValidator.cfc and let me know if it does in fact fix the problem
on your end.

Cheers,
Bob
--
Bob Silverberg
www.silverwareconsulting.com

Alexander Sante

unread,
Jul 29, 2009, 5:31:20 PM7/29/09
to valida...@googlegroups.com
Yep, that works too.

Bob Silverberg

unread,
Jul 29, 2009, 5:59:39 PM7/29/09
to valida...@googlegroups.com
Great. Thanks for giving it a try. It'll be in the next release.

On Wed, Jul 29, 2009 at 5:31 PM, Alexander Sante<al...@gearsource.com> wrote:
>
> Yep, that works too.
>
> On Jul 29, 2009, at 5:24 PM, Bob Silverberg wrote:
>
>>

--
Bob Silverberg
www.silverwareconsulting.com

Bob Silverberg

unread,
Jul 30, 2009, 10:48:26 PM7/30/09
to valida...@googlegroups.com
This has been fixed in version 0.85.

--
Bob Silverberg
www.silverwareconsulting.com

Reply all
Reply to author
Forward
0 new messages