| 1 | use strict; |
| 2 | use warnings; |
| 3 | |
| 4 | use Test::More tests => 4; |
| 5 | |
| 6 | use HTML::FormFu; |
| 7 | use lib 't/lib'; |
| 8 | use HTMLFormFu::TestLib; |
| 9 | |
| 10 | my $form = HTML::FormFu->new; |
| 11 | |
| 12 | $form->load_config_file('t/repeatable/constraints/when.yml'); |
| 13 | |
| 14 | $form->get_element( { type => 'Repeatable' } )->repeat(1); |
| 15 | |
| 16 | # Valid |
| 17 | { |
| 18 | $form->process( |
| 19 | { 'rep_1.foo' => 'a', |
| 20 | 'rep_1.bar' => 'b', |
| 21 | count => 1, |
| 22 | } ); |
| 23 | |
| 24 | ok( $form->submitted_and_valid ); |
| 25 | } |
| 26 | |
| 27 | # Missing - Invalid |
| 28 | { |
| 29 | $form->process( |
| 30 | { 'rep_1.foo' => 'a', |
| 31 | 'rep_1.bar' => '', |
| 32 | count => 1, |
| 33 | } ); |
| 34 | |
| 35 | ok( $form->has_errors ); |
| 36 | |
| 37 | ok( $form->valid('rep_1.foo') ); |
| 38 | ok( !$form->valid('rep_1.bar') ); |
| 39 | } |
| 40 |