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

Christopher H. Laco claco at chrislaco.com
Tue May 16 02:38:33 CEST 2006


Christopher H. Laco wrote:
> /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

I've attached a patch to do what I described to validate().

-=Chris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DBIx-Class-Validation.pm.patch
Type: text/x-patch
Size: 892 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060515/3b23599c/attachment.bin 
-------------- 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/20060515/3b23599c/attachment.pgp 


More information about the Dbix-class mailing list