Coldbox - property was not found in the object passed into the validation object.

5 views
Skip to first unread message

Liam

unread,
Aug 14, 2009, 12:48:54 AM8/14/09
to ValidateThis
Hi all

I am loving the ValidateThis framework with Coldbox - esp. how easy it
is to have client and server side validation.

However, I've come across one problem. I have a form that has two
email addresses - the standard: please enter your email address and
please confirm your email address.

This works fine on the client side validation, but when it returns to
the server I get an error, because the emailConfirm field doesn't
exist in the member object.

I am populating the bean using the beanFactory plugin prior to calling
the validate this plug:
The problem is that the field 'emailConfirm' doesn't exist in the
member object, it only exists in the form
My code is:
objMember = instance.MemberService.getMember(memberId:
session.member.getMemberID());
getPlugin("beanFactory").populateFromStruct(objMember,rc.formData);

rc.VTResult = getPlugin("ValidateThis").validate
(theObject=objMember,objectType="Member",context="email-address");

The error I get is:

Application Execution Exception
Error Type: Application : validatethis.validation.propertyNotFound
Error Messages: The property emailConfirm was not found in the object
passed into the validation object.

Any ideas around this? Sorry if I've missed something really obvious!
Cheers
Liam

Gmail

unread,
Aug 14, 2009, 9:28:05 AM8/14/09
to valida...@googlegroups.com
I don't think you've missed anything "obvious" but there are a couple
of ways around this.

1. You could add a property to your object for emailConfirm. It
doesn't have to be a persistent property - just add a getter and a
setter for it.

2. This is a bit more complicated, and a bit "hacky", but you could
add a condition that would have a ServerTest that evaluates to "false"
and then specify that as the condition for that rule. Check out the
brand new docs for some info on conditions. I actually haven't even
tested this scenario - a condition with only a server test, but I
think it would work. If not, I'm sure that a condition with a
ServerTest that evaluates to false and a ClientTest that evaluates to
true would work.

This does raise an interesting use case, though. That is, should it be
possible to mark a rule as "server only" or "client only"? I hadn't
encountered that before, as I generally want all rules enforced
everywhere.

Another option would be for the framework to not throw an error when a
property doesn't exist, and instead ignore the rule, but that seems
pretty unsafe to me.

Does anyone else have any opinions on the above?

Sorry if my note is a bit lacking in detail, but I'm actually away on
vacation right now and only have my iPhone for Internet access.

Cheers,
Bob

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages