self validating bean object

Senario:

I created an instance of a bean in my handler via my service. I want
my bean to self validate. The issue is, when I call populateModel it
implicitly validates properties based on their type attribute (i.e if
I set the property to 'date' or 'numeric'). So before I can even call
myBean.validate() validation has already occurred. My way around this
(and I'm not proud of it) is by not declaring a property type and only
validating the bean when I call the validate method.

I think this is a common issue and I was wonder how people have solved
it using Coldbox or Coldfusion. I am currently using coldfusion 9.

Regards,
Justin

Don’t use the type attribute at all, then you can populate with any data. If you want to hibernate to create columns then use the ormtype attribute to tell hibernate what datatype the column is.

I don’t use the type attribute either. I just handle the validation within my validate() function using the Validation.cfc that ColdBox offers. I’ve extended mine a bit to some other things, but I have it setup as a core Class in a sense and I can override it on a per project basis if I need to.

I guess more than one way to skin a cat…

It would be nice if ColdFusion had the concept of events and listeners as
this would be perfect here, if I am understanding you right the only real
option I can see is that the setter in the bean could call the validation of
that type in the hyrule package.

I can't think of any other way this could be done.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of justin
Sent: Saturday, 2 October 2010 2:52 AM
To: ColdBox Platform
Subject: [coldbox:6039] self validating bean object

Senario:

I created an instance of a bean in my handler via my service. I want my

bean

to self validate. The issue is, when I call populateModel it implicitly

validates

properties based on their type attribute (i.e if I set the property to

'date' or

'numeric'). So before I can even call
myBean.validate() validation has already occurred. My way around this (and
I'm not proud of it) is by not declaring a property type and only

validating the