I'd say the overall answer is the standby: "It depends."

There's nothing wrong with using the CFC you mentioned, if it still suits
your needs.

One of the frequently used features of Model-Glue (or Mach-II, for that
matter) is the ability to automagically populate a bean from a form
submission. This could be a bean you build yourself; or it could be
something like a Record object created by a framework like Reactor or
Transfer.

The bean encapsulates the form submission -- and most likely represents a
record headed for your database. You could then call methods in your
validation CFC and pass in getters from the bean, like isEmail(bean.getEmail).
If the validations pass, you then use the bean to do whatever's next -- like
update the database.

Record objects created by the ORM frameworks often have their own validation
methods, which can be extended.

As far as when/where you do your validation -- strictly it should probably
be done within the model, in a business object of some kind. Your validation
rules may be more than just validating an e-mail address. They might involve
comparisons of two values from the form submission, or checking against some
other value. So they're really business rules.

On the other hand -- there's no big reason to complicate things either. If
all you're doing is basic stuff like validating e-mail addresses, whether or
not a value is numeric, and things like that, I don't think anyone will
shoot you for doing it within the controller.

As far as error handling goes, a typical scenario would be to create a
message based on the validation failure, stuff it into the event --
event.setValue("errorMessage"), then create a Result which would announce
the event calling the form page again.

-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273170
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to