Skye Shaw wrote:
Hi,

Does anyone find it odd that DBIx::Class::Validation croaks when
validation fails via $obj->validate?

I understand the need to do this on insert & update, but it seems a
little unorthodox writing code like the following just to check the
validation result:

my $result;
eval { $result = $obj->validate };
$result = $@ if $@;

This can become (more) cumbersome if the validation involves querying the DB.

This is why you write:

try {
  my $good_result = $obj->validate;
  do stuff with good result
} catch {
  my $bad_result = $_
  do stuff with bad result
};

Or if you "do stuff" the same:

my $result = try { $obj->validate } catch { $_ };

Exception based control flow is very common and very useful. You can't ignore
it or forget about it unlike the pesky:

return $ok ? ($ok_ret) : (undef, $fail_ret)

_______________________________________________
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]

Reply via email to