Skip Menu |

This queue is for tickets about the Data-FormValidator CPAN distribution.

Maintainer(s)' notes

This is the bug queue for Data::FormValidator.

Report information
The Basics
Id: 30396
Status: open
Priority: 0/
Queue: Data-FormValidator

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in:
  • 4.50
  • 4.51
  • 4.52
  • 4.53
  • 4.54
  • 4.55
Fixed in: (no value)



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", ); }
I went over this with RJBS on IRC. In summary: The behavior he ran into was an undocumented feature that worked at some point, but quit working. We agreed to improve the situation by die'ing with a helpful error when the case is encountered, since it was not intended to be supported. [21:16] <rjbs> I suggest you at *least* add a Carp::confess saying, "You have a hashref in your constraint methods! That only worked in the past by accident. Move it to constraints or rewrite it as code."