2011/1/17 Seth Daniel <[email protected]>: > On Mon, Jan 17, 2011 at 09:19:13AM -0200, Eden Cardim wrote: >> >>>>> "Seth" == Seth Daniel <[email protected]> writes: >> >> Seth> Hi, I was wondering what is the preferred way to cleanse and >> Seth> validate incoming data when using DBIx::Class? > [...snip...] >> >> Personally, I've found that a generic validation solution is only >> adequate for the most trivial cases, like constraining an int to a >> certain range of values or checking for email well-formedness. For >> anything more complex than that, like checking for uniqueness or >> building a list of the possible values that are allowed for a certain >> field, I'd say you're better off writing your own logic, YMMV. > > I was mostly thinking of trivial cases. i.e. a simple check to verify > the column meets a certain pattern or is a certain type. Curiously, why > would I need to check for uniqueness? Every database I plan on using > does this for me (which isn't to say that every database DBIx::Class > supports does this). > > >> Seth> So beyond data validation I'd like any opinion on the *proper* way >> to >> Seth> cleanse data before it gets placed in the database. Mostly I'm >> just >> Seth> looking for a way to make certain varchar columns are all lower >> case. >> Seth> I'm also looking for a good way to validate the incoming data for >> Seth> certain columns. Again, I was hoping using MooseColumns would >> allow me >> Seth> to use Moose's type system, but since the accessors don't get >> called for >> Seth> some common DBIx::Class methods the usefulness is less than I had >> hoped. >> >> How about wrapping the relevant API calls with Params::Validate? > > 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 > checking at a higher level will work, but seems like a lot more effort > since I'd have to check the same columns over and over in different API > calls. > > -- > seth /\ sethdaniel.org > > _______________________________________________ > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class > IRC: irc.perl.org#dbix-class > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ > Searchable Archive: http://www.grokbase.com/group/[email protected] > -- Sincerely yours, Oleg Kostyuk (CUB-UANIC) _______________________________________________ List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[email protected]
