[Dbix-class] best way to cleanse / validate data

Seth Daniel dbix-class at sethdaniel.org
Mon Jan 17 09:19:02 GMT 2011


Hi,

I was wondering what is the preferred way to cleanse and validate
incoming data when using DBIx::Class?

I read with some interest a thread from 2009
(http://lists.scsys.co.uk/pipermail/dbix-class/2009-July/008241.html)
that discussed validation.  Is DBIx::Class::Validation still considered
a good way to go?

I initially thought I could use DBIx::Class::MooseColumns.  I converted
my Result classes to use MooseColumns and then created a trait that
converted the given value to all lower case.  While the trait works
fine, and having moose-ish columns is great, it seems that the accessor
is not called very often, so my experiment failed (the only time the
data to be placed in the database was lower cased was when I called the
accessor directly.  create() and similar don't seem to call the
accessor (unless it's an inflated column)).

So beyond data validation I'd like any opinion on the *proper* way to
cleanse data before it gets placed in the database.  Mostly I'm just
looking for a way to make certain varchar columns are all lower case.
I'm also looking for a good way to validate the incoming data for
certain columns.  Again, I was hoping using MooseColumns would allow me
to use Moose's type system, but since the accessors don't get called for
some common DBIx::Class methods the usefulness is less than I had hoped.

-- 
seth /\ sethdaniel.org



More information about the DBIx-Class mailing list