Skip Menu |

This queue is for tickets about the Params-Validate CPAN distribution.

Report information
The Basics
Id: 29145
Status: resolved
Priority: 0/
Queue: Params-Validate

People
Owner: Nobody in particular
Requestors: Anonymous (no email address)
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: on_fail always dies in XS, but behaves properly in PP
Date: Mon, 3 Sep 2007 22:46:49 +0200 (CEST)
To: bug-Params-Validate [...] rt.cpan.org
From: Anonymous <cripto [...] ecn.org>
the following example demonstrates inconsistency between XS and PP regarding on_fail. run with and without PV_TEST_PERL=1 -- use strict; use warnings; BEGIN { package Foo; our $error; use Params::Validate qw( :all ); validation_options( on_fail => sub { $error = $_[0] } ); sub new { my $class = shift; validate( @_, { bar => 1 } ); } } my $foo = Foo->new(); #print $Foo::error, "\n";
On Mon Sep 03 18:53:15 2007, cripto@ecn.org wrote: Show quoted text
> the following example demonstrates inconsistency between XS > and PP regarding on_fail. > > run with and without PV_TEST_PERL=1 > -- > use strict; > use warnings; > BEGIN { > package Foo; > our $error; > use Params::Validate qw( :all ); > validation_options( on_fail => sub { $error = $_[0] } ); > sub new { > my $class = shift; > validate( @_, { bar => 1 } ); > } > } > > my $foo = Foo->new(); > #print $Foo::error, "\n";
This is a known problem. The XS code expects the on_fail callback to abort execution. If it doesn't everything goes to heck. That's why the docs says "this callback is expected to "die()" internally. If it does not, the validation will proceed onwards, with unpredictable results."