Great writeup Doug. I just had one bit of advice (I added a comment but I'll post it here too):
Doug, very nice summary. One thing I would do though (as Adam mentioned) is not have database query logic in the Validator. Just grab an instance of the proper Reactor gateways and check for dups either using the gateway methods (in this case it's a simple getByFields call) or using a custom Gateway method. In either case, keep the queries where they belong, in DAOs or Gateways, not in the Validator. Otherwise, great writeup! On 5/25/07, Doug Boude <[EMAIL PROTECTED]> wrote:
Hi Doug (great name, by the way). Since you opted to enforce your email value's uniqueness via database rules, I'm not sure if the following blog post is totally relevant to you, but since I recently had to do the exact same thing that you're describing, thought I'd take the time to share how I approached and solved it. http://www.dougboude.com/blog/1/2007/05/Custom-Validation-with-Generic-Commit-a-ModelGlue-Case-Study.cfm Doug :0) On 5/24/07, Doug Arthur <[EMAIL PROTECTED]> wrote: > Hi, > > I'm using MG:Unity + Reactor. I'm using a modelglue.GenericCommit and I have > a unique index so the database cannot have multiple email addresses of the > same. How can I get validation to work rather than it throwing a hard error? > Does reactor not catch this in validation? I think it would be nice, if > nothing more to check the SQL error that is thrown back for "Cannot insert > duplicate key". I'm using the validation structure for when users don't > enter a value in a non-null field, or enter an incorrect data type and/or > length. > > > Thanks, > - Doug > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- > Reactor for ColdFusion Mailing List > [EMAIL PROTECTED] > Archives at: > http://www.mail-archive.com/reactor%40doughughes.net/ > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
