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

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

On Mon, Jan 17, 2011 at 08:49:30PM +0200, Oleg Kostyuk wrote:
> 2011/1/17 Seth Daniel <dbix-class at sethdaniel.org>:
> > It seemed to me the lowest level I could do this type of checking was
> > the accessor.  This turned out to be incorrect.  Certainly, doing the
> IIRC, lowest level is store_column()
> http://search.cpan.org/~arcanez/DBIx-Class-0.08126/lib/DBIx/Class/Row.pm#store_column

You are correct, as I discovered when trying to figure out why the
accessors I built with DBIx::Class::MooseColumns weren't getting called.
Is extending my result classes and doing validation/cleansing that way a
good idea?

Hm, POD for DBIx::Class::Row suggests it may be:  

    This is the lowest level at which data is set on a row object, extend
    this method to catch all data setting methods.

(of course it also says 'This method is used internally by "set_column"
which you should probably be using')

DBIx::Class::Validation takes a slightly different approach and extends
update and insert.  I'll need to check if DBIC::Validation can do data
normalization.  I don't believe it can.  But it plus extending
store_columns may be what I'm looking for.


seth /\ sethdaniel.org

More information about the DBIx-Class mailing list