Luis Majano Forums Notification: Post to Form Validation

Title: RE: Form Validation
Thread: Form Validation
Forum: Need Help?
Conference: ColdBox
User: lmajano

You have an excellent point Oscar, especially when you are dealing with dates,
when you pass an empty string to a function requiring a date, then the call will
fail.

Internall, the beanfactory populates a bean by setter calls. If a
method is found in the cfc with the correct signature, it will call it and pass
as an argument the same value in the request collection. Example:

CFC
contains a method called 'setName( name:String )'

The factory will call the
setName() method and pass the 'name' value of the request collection into the
method.

Your point of type mysmatches or invalid data give rise to an
interesting idea. What if by convention, the bean itself has a onPopulateError
method that could be called by the beanfactory if for some reason the setter
call fails. It can call the onPopulateError method on the bean itself and pass
in the exception. This method could then decide if its a real exception or if
its type mismatches, basically set the error property with the correct message
for the user and do clean validation. Am I just going totally funky here or no?
This is really something, this goes to something along the lines of an
onMissingMethod() that coldfusion 8 now immplements. You can dynamically morph
the bean to do validation or whatever by convention.

Ok, I think I over did
it, but what do you think?

http://www.luismajano.com/forums/index.cfm?event=ehMessages.dspMessages&threadid=099E0187-123F-6116-421FA3B9B2F4006A