4.50 broke backcompat by disallowing the construction (in
constraint_methods):
field => [ hashref, hashref, ... ]
There is no warning in the documentation, changelog, or install
procedure about this.
This caused me some serious inconvenience today. :(
Test and results attached, showing success before and failure after 4.50
--
rjbs
Subject: | results.txt |
TESTING Data-FormValidator-4.02
1..4
ok 1 - no errors
ok 2 - foo valid
ok 3 - datum invalid
ok 4 - datum fails because of the 'fails' constraint
TESTING Data-FormValidator-4.40
1..4
ok 1 - no errors
ok 2 - foo valid
ok 3 - datum invalid
ok 4 - datum fails because of the 'fails' constraint
TESTING Data-FormValidator-4.50
1..4
not ok 1 - no errors
# Failed test 'no errors'
# at dfv.t line 31.
# got: 'Value for constraint_method within hashref '' not a code reference or Regexp . Do you need func(), not 'func'? at Data-FormValidator-4.50/lib/Data/FormValidator.pm line 959.
# '
# expected: ''
not ok 2 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
not ok 3 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
not ok 4 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
# Looks like you failed 4 tests of 4.
TESTING Data-FormValidator-4.56
1..4
not ok 1 - no errors
# Failed test 'no errors'
# at dfv.t line 31.
# got: 'Value for constraint_method within hashref '' not a code reference or Regexp . Do you need func(), not 'func'? at Data-FormValidator-4.56/lib/Data/FormValidator.pm line 960.
# '
# expected: ''
not ok 2 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
not ok 3 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
not ok 4 - died; no results
# Failed test 'died; no results'
# at dfv.t line 33.
# Looks like you failed 4 tests of 4.
Subject: | dfv.t |
use strict;
use warnings;
use Data::FormValidator;
use Test::More tests => 4;
my $profile = {
required => [ qw(datum foo) ],
constraint_methods => {
datum => [
{
constraint => sub { 1 },
name => 'passes',
},
{
constraint => sub { 0 },
name => 'fails',
},
],
},
};
my $result = eval {
Data::FormValidator->check(
{ datum => 1, foo => 1 },
$profile,
);
};
is($@, '', "no errors");
if ($@) {
fail('died; no results') for 1 .. 3;
} else {
is_deeply(
[ $result->valid ],
[ qw(foo) ],
'foo valid'
);
is_deeply(
[ $result->invalid ],
[ qw(datum) ],
'datum invalid',
);
is_deeply(
$result->invalid('datum'),
[ 'fails' ],
"datum fails because of the 'fails' constraint",
);
}