[Catalyst] Making Controllers thin and Models thick

John Napiorkowski jjn1056 at yahoo.com
Wed Jul 18 20:01:05 GMT 2007


--- Kee Hinckley <nazgul at somewhere.com> wrote:

> On Jul 18, 2007, at 10:49 AM, John Napiorkowski
> wrote:
> > validating types for your columns.  I do this for
> very
> > common things like email addresses.  Postgresql is
> > nice for this since you can create custom types
> and
> > domains using Perl as your procedural language.
> 
> <pet-peeve>
> Please tell me you're either doing *real* email
> validation (e.g.  
> Mail::Address), or something overly lax..  Aside
> from sites that  
> won't let me enter valid email addresses (keep in
> mind that just  
> about the only character not legal in an email
> address is NUL).  I've  
> even had sites who "updated" their validation such
> that people who  
> previously had accounts could no longer login.  ("+"
> is the really  
> common one to get rejected, but I had a friend who
> had his email  
> rejected once because it had a "-" in the domain
> name!)
> 
> My rule of thumb on email validation is "don't
> bother".  Or rather,  
> if you really care, send mail to it and ask them to
> respond.  After  
> all, just because it's valid doesn't mean it
> *works*.  I think a lot  
> of sites do it "just because".  Originally it was
> done because people  
> kept "making mistakes."  Of course the most of the
> mistakes were  
> intentional attempts to avoid getting spammed
> (somewhere.com was  
> *real* popular for fake addresses).
> 
> If you're just checking for typos "/.+\@.+\..+/" is
> probably  
> sufficient.  (Assuming of course that you don't want
> me to enter  
> "somewhere.com!nazgul" as my email address, even
> though it might well  
> work, and is certainly "legal".)
> </pet-peeve>

I use a standard perl module for this which is part of
a custom function and domain in Postgresql.  Since we
send the user an email with a validation token to
activate an account, doing strict email testing cuts
down on the number of bad emails that get bounced
back.

I also hate those forms that ask for an email for no
reason, other than they want you in their database.

> 
> > I end up mirroring a lot of this in DBIC using
> > DBIC::Validate since I'd rather catch syntactical
> > errors in my code instead of throwing a database
> > error.  For me that's the last line of defense.
> 
> Are you referring to DBIx::Class::Validation, or is
> there another  
> module.  I looked at that, but it didn't seem to
> make any use of the  
> actual schema data.

Doh, yeah, I always get the name wrong.  You'd think
I'd remember since I used it so much on my last
project.


> 
> > I tend to think of this as 'spell checking versus
> > grammar checking'.  Your domain code is the
> grammar
> > for a particular business activity.  At least I
> think
> > of it that way.
> 
> That's a good metaphor.
> 
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo:
> http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
>
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
> 



      ____________________________________________________________________________________
Luggage? GPS? Comic books? 
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz



More information about the Catalyst mailing list