The property [n] was not found in the object passed into the validation object.

17 views
Skip to first unread message

Rawlins

unread,
Mar 23, 2012, 6:27:54 AM3/23/12
to valida...@googlegroups.com
Hello Guys,

I've got a strange issue which has crept in at some point. I have an object that has validation on a virtual property, this means the property doesn't technically exist (no getter/setter), but the rules that apply to it are all custom so it shouldn't need to invoke the property directly.

<property name="NoRemainingStock" desc="No remaining stock">
<rule type="custom" contexts="delete" failureMessage="You cannot delete a stock location whilst it still contains stock.">
<param name="methodName" value="hasNoRemainingStock" />
</rule>
</property>

When I try to validate this object I get an error:

               The property NoRemainingStock was not found in the object passed into the validation object.

Now, I'm sure this was working several weeks ago when we built the feature, however, I believe at some point I may have upgraded the framework (from 0.99) and this issue obviously slipped through my testing.

Looking through GitHub it seems that some work was done on a ignoreMissingProperty feature - that results in exceptions like this. It seems I have to now pass a new argument into the validate() method if my object has virtual properties like this, is that correct?

If so, then this causes quite a lot of extra leg work for me as a developer as I use virtual properties like this quite extensively. Is it possible to suggest that we have the default for this setting as a framework wide configuration?

Can anyone offer any advice / opinions?

Thanks guys,

Robert

Bob Silverberg

unread,
Mar 23, 2012, 9:26:19 AM3/23/12
to valida...@googlegroups.com
Are you able to isolate the code in the fw that's causing a problem?
It does seem to me that if you are only doing a custom validation that
it shouldn't care whether the property exists or not, so maybe a fix
can be made which wouldn't require any defaults to change. I'll look
into it when I can, but I figured that if you've been looking at the
code maybe you can point out exactly where the problem is occurring.

Thanks,
Bob

> --
> You received this message because you are subscribed to the Google Groups
> "ValidateThis" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/validatethis/-/hibB8I1G-XMJ.
> To post to this group, send email to valida...@googlegroups.com.
> To unsubscribe from this group, send email to
> validatethis...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/validatethis?hl=en.

--
Bob Silverberg
www.silverwareconsulting.com

Robert Rawlins

unread,
Mar 23, 2012, 9:30:55 AM3/23/12
to valida...@googlegroups.com
Hi Bob,

It's line 121 of ServerValidator.cfc that throws the exception.

Basically when validating it calls val.PropertyExists() - if it doesn't then it throws the exception.

I think you may be right, a slight change so that the property existing is only a requirement if you're using non-custom rules that will require the getter.

Thanks.

Rob

Bob Silverberg

unread,
Mar 23, 2012, 9:50:24 AM3/23/12
to valida...@googlegroups.com
Maybe. But it might not be a good idea to start coding edge cases
into there. I'll take a look.

Thanks,
Bob

--
Bob Silverberg
www.silverwareconsulting.com

Bob Silverberg

unread,
Mar 23, 2012, 4:05:46 PM3/23/12
to valida...@googlegroups.com
OK, I think it does make sense to code just for the Custom type in
this case, as it is a special case, and I don't think there will be
others.

I have updated ServerValidator.cfc to address this and have pushed the
changes to https://github.com/ValidateThis/ValidateThis. You can pull
from the develop branch, or just replace ServerValidator.cfc in your
install with the one attached to this post.

Let me know if this resolves the problem for you,
Bob

--
Bob Silverberg
www.silverwareconsulting.com

ServerValidator.cfc
Reply all
Reply to author
Forward
0 new messages