1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
use strict;
use warnings;
use Test::More tests => 4;
use HTML::FormFu;
my $form = HTML::FormFu->new;
$form->auto_fieldset( { nested_name => 'foo' } );
$form->element('Text')->name('bar')->constraint('DependOn')
->others([qw/ foo.baz foo.bag /]);
$form->element('Text')->name('baz');
$form->element('Text')->name('bag');
# Valid
{
$form->process( {
'foo.bar' => 1,
'foo.baz' => 'a',
'foo.bag' => [2],
} );
ok( !$form->has_errors );
}
# Invalid
{
$form->process( {
'foo.bar' => 1,
'foo.baz' => '',
'foo.bag' => 2,
} );
ok( !$form->has_errors('foo.bar') );
ok( $form->has_errors('foo.baz') );
ok( !$form->has_errors('foo.bag') );
}
|