Thanks for the great post Doug! Really excellent work, and I'm glad you
decided to post that up because I really needed it.

- Doug (nice to see a lot of Doug's in the community, hehe)


On 5/25/07, Brian Kotek <[EMAIL PROTECTED]> wrote:

Great Doug, the example now keeps the SQL out of the Validator. I added
one more comment to the blog as well:

I would probably go one step further and make the custom validation events
more self-contained. In other words, don't pass in the UserRecord to
validateEmail(), just pass the email value as the first argument, and add a
default to the second argument (the ErrorCollection) to create it if it
isn't passed (just like the validate() method does). What does this gain
you? You can now validate the unique email by itself if you want to just by
calling validateEmail() on your Validator and passing in the email address
to be validated. This is great for an AJAX system for example, where you
might run an AJAX request in the background when they enter their email
address to validate just that field in real time. You can still validate as
part of a full UserRecord validation too.

Unfortunately, the generated validation methods don't do this (they
require the UserRecord), but it would be a very simple fix to Reactor to
have it pass in the actual values instead of the whole Record to the
validation methods. I may run this past Doug and add an enhancement request.
Then you'd be able to call either your custom validation methods or the
generated validation methods one by one OR on a whole Record.

On 5/25/07, Brian Kotek <[EMAIL PROTECTED]> wrote:
>
> 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.GenericCommitand 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/
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> -- -- --
>


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to