Skip Menu |

This queue is for tickets about the HTML-FormFu CPAN distribution.

Report information
The Basics
Id: 65728
Status: resolved
Priority: 0/
Queue: HTML-FormFu

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

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



Subject: filter split broken constraint minmaxfields
because filter Split always return an array even if no value is given, constraint MinMaxFields doesn't work as expected. since it changes filter Split's behaviour, hope that the patch is acceptable. -- http://islue.blogspot.com/
Subject: constraint_minmaxfields_with_filter_split.t
use strict; use warnings; use Test::More tests => 7; use HTML::FormFu; my $form = HTML::FormFu->new; $form->load_config_file('t/constraint_minmaxfields_with_filter_split.yml'); # Valid { $form->process( { foo => '', bar => '', baz => '', } ); ok( !$form->has_errors ); $form->process( { foo => '1', bar => '', baz => '', } ); ok( !$form->has_errors ); $form->process( { foo => '1,2', bar => '', baz => '', } ); ok( !$form->has_errors ); } # Invalid { $form->process( { foo => 1, bar => '', baz => 2, } ); ok( $form->has_errors ); ok( !$form->valid('foo') ); ok( $form->valid('bar') ); ok( $form->valid('baz') ); }
Subject: constraint_minmaxfields_with_filter_split.yml
--- elements: - name: foo constraints: - type: MinMaxFields others: - bar - baz min: 0 max: 1 filters: - type: Split regex: ',' - name: bar filters: - type: Split regex: ',' - name: baz filters: - type: Split regex: ','
Subject: HTML-FormFu-Filter-Split.diff
20c20,22 < return \@values; --- > return if !scalar @values; > > return $#values ? \@values : pop @values;
I've applied the fix so it doesn't return a value if one wasn't submitted. However, I've not applied the change to return a scalar value if split didn't result in multiple values. I think it's more consistent if all fields with a Filter::Split always return an array-ref. - thanks