[Catalyst] Form validation in insert() and update()?

mla maurice.aubrey at gmail.com
Tue May 15 00:24:38 GMT 2007


Dave Rolsky wrote:
> On Mon, 14 May 2007, mla wrote:
>> Could you give an example of how you munge the exceptions into error
>> messages for the user?
> 
>  eval
>  {
>      $user->update( %bunch_of_stuff );
>  };
> 
>  if ( my $e = Exception::Class->caught( 
> 'My::App::Exception::DataValidation') )
>  {
>      # $e->errors contains multiple data validation error messages
>      # stuff them in the session
>      # save the user's form submission in the session
>      # redirect back to form
>  }
>  elsif ( my $e = $@ )
>  {
>      die $e;
>  }
> 
> Then on the display side, I check the session for error messages and 
> saved form arguments, and do something useful with them.

That's excellent. Thank you. I'm going to throw together an experimental
page using this idiom.

Maurice



More information about the Catalyst mailing list