File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ use strict;
2+ use warnings;
3+ use Test::More;
4+
5+ {
6+ package MyApp::Field::DuplicateText ;
7+ use HTML::FormHandler::Moose;
8+ extends ' HTML::FormHandler::Field::Text' ;
9+
10+ apply [ {
11+ transform => sub {
12+ my $value = shift ;
13+ # collapses down to a single entry if passed a list where all
14+ # values are identical
15+ return $value -> [0] if
16+ defined $value
17+ and ref $value eq ' ARRAY'
18+ and map { $value -> [0] eq $_ } @$value ;
19+ return $value ;
20+ },
21+ }];
22+ }
23+
24+
25+ # tests the TextCSV field
26+ {
27+ package MyApp::Form::Test ;
28+ use HTML::FormHandler::Moose;
29+ extends ' HTML::FormHandler' ;
30+
31+ has_field ' foo' => ( type => ' +MyApp::Field::DuplicateText' );
32+ has_field ' bar' => ( type => ' +MyApp::Field::DuplicateText' );
33+ }
34+
35+ my $form = MyApp::Form::Test-> new;
36+ ok( $form );
37+ $form -> process( params => { foo => ' 1' , bar => [' 2,2' ] } );
38+
39+ TODO: {
40+ local $TODO = ' this test broke with commit 0cae37c6' ;
41+
42+ ok($form -> validated, ' field of list values validates' )
43+ or diag ' got errors: ' , explain [ $form -> errors_by_name ];
44+
45+ }
46+
47+ done_testing;
You can’t perform that action at this time.
0 commit comments