Re: Data validation

[prev] [thread] [next] [Date index for 2004/11/10]

From: Perrin Harkins
Subject: Re: Data validation
Date: 21:20 on 10 Nov 2004
On Wed, 2004-11-10 at 09:38, Kingsley Kerce wrote:
> (BTW, if this is too off-topic for
> CDBI, what forums are appropriate?  I'm familiar with the c2 wiki, but
> it's often over-abstract.)

If you're using mod_perl for your application, the mod_perl mailing list
is a good place for discussing how to structure web apps.

> Why not perform all -- or most -- data validation at the RDBMS level?

Others have pointed out that many people aren't using Postgres or don't
like the way they have to specify these things with Postgres.  I would
add that there are many kinds of validation which are difficult to do 
even with Postgres, unless you use perl inside the database.  You may
want to run regexes, or use modules that encapsulate some tricky
business logic, or validate things in a way that depends on something
else about the current state of the application.  These are easy with
Class::DBI, but not with a database.

Yes, you could run a perl interpeter inside Postgres, but I find that
objectionable on many levels, the simplest being that the database is
pretty much always the bottleneck in web apps and my goal is to drag
stuff out of it, not put more into it.  I still use basic referential
integrity checks in any database that supports it, but I don't do more
than that at this level.

I've tried validation in various places over the years.  In theory, your
data access objects, i.e. Class::DBI, are the right place to do it. 
Putting this kind of information in your controller code makes it
tightly coupled to your data model and screws up your encapsulation. 
You don't want your shopping cart controller to know about credit card
formats; you want your order class to know about them.

The problem is that when you do it this way you end up having to write
code that carefully checks for exceptions on all of your calls to
Class::DBI objects (or maybe just updates, but somewhere it has to
check), and then ferries any errors up to the template for display. 
This isn't so bad, but it's more work than the very easy
Data::FormValidator approach.  You also have potential problems with
non-transactional databases if the error checking is not done until
objects try to update, and some go through while others fail.  Not an
issue for InnoDB, Postgres, Oracle, etc.

Anyway, at this point, although I think it's probably the wrong place to
do it, I use Data::FormValidator because it's so easy.

- Perrin

(message missing)

Data validation
Drew Taylor 20:39 on 09 Nov 2004

Re: Data validation
Drew Taylor 20:44 on 09 Nov 2004

Re: Data validation
Perrin Harkins 22:08 on 09 Nov 2004

Re: Data validation
Drew Taylor 22:14 on 09 Nov 2004

Re: Data validation
Edward J. Sabol 23:20 on 09 Nov 2004

Re: Data validation
Drew Taylor 01:15 on 10 Nov 2004

Re: Data validation
Dan Sully 01:40 on 10 Nov 2004

Re: Data validation
Perrin Harkins 06:42 on 10 Nov 2004

Re: Data validation
Dan Sully 06:59 on 10 Nov 2004

Re: Data validation
Drew Taylor 14:56 on 10 Nov 2004

Re: Data validation
Drew Taylor 15:03 on 10 Nov 2004

Re: Data validation
Perrin Harkins 22:03 on 10 Nov 2004

Re: Data validation
Kingsley Kerce 14:38 on 10 Nov 2004

Re: Data validation
Drew Taylor 15:17 on 10 Nov 2004

Re: Data validation
Tony Bowden 19:28 on 10 Nov 2004

Re: Data validation
Perrin Harkins 21:20 on 10 Nov 2004

Re: Data validation
Cees Hek 23:52 on 10 Nov 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52