A Validator component is a very good place to wrap up validation logic. However, I would probably populate the business object and then have it run a validate() method (either called explicitly or something the bean does automatically internally), and have the Validator composed into the business object which handles the validation chores. If you don't want to compose the Validator into the business object, you could also populate the business object and then pass it into a Validator to determine if the data is valid. But either way, yes, the Validation code itself is a good candidate for encapsulation into its own CFC. So you could either do:
user.init(formValues) user.validate() or user.init(formValues) userValidator.validate(user) Hope that helps. Brian On 5/31/07, Anthony Tinoco <[EMAIL PROTECTED]> wrote:
Hi All, As my understanding of cfc development has increased, I am still left wanting in my understanding of where to put form validation logic. Currently, I am putting the form validation logic in the business objects, such as is the form field blank, is it a credit card, is it a phone number, is it an e-mail address, etc. It just seems like this stuff should be handled before getting to the business object. Maybe this comes from my previous experience of working with the Struts Framework which removed form validation logic from the business objects. Would it be best to handle this stuff in a separate validation.cfc which would validate the form and then create a form bean to be passed to the business object upon successful validation? Thoughts would be greatly appreciated on this subject, Anthony You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
