[Dbix-class] Proposed DBIx::Class::Validate Changes

Christopher H. Laco claco at chrislaco.com
Fri May 12 21:44:39 CEST 2006


/claco arises from the land of the dead

Now that I've ditched a majority of my distractions (a zillion email
lists and rss feeds, irc, icq, im, etc), I've finally got a good
foothold on the Handel redesign using DBIC schemas.

So far so good; great in fact. One of the changes I'm making is to move
towards using Validate as a replacement for the old CDBI constraints. A
couple of hacks later; making my Exception/Constraint::check pretend to
be FormValidator::Simple, everything is pretty much working. The only
feature I can't replicate is the fact that CDBI constraints could
actually change the column values if they needed to.

Since this is apparently not possible in the Validation module, I'd like
to propose the following minor change:

Allow validate() to call set_columns() with the \%data it already has
upon success():

> sub validate {
>     my $self = shift;
>     my %data = $self->get_columns();
>     my $module = $self->validation_module();
>     my $profile = $self->validation_profile();
>     my $result = $module->check( \%data => $profile );
>     if (blessed $result && $result->success()) {
>     	$self->set_columns(\%data);
> 	return $result;
>     } else {    
>     	$self->throw_exception( $result );
>     };
> }

I don't think that should effect anything else, but the tests will tell
the story. If no one has any objections, I'll work up a patch.

-=Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060512/ac725b17/attachment.pgp 


More information about the Dbix-class mailing list