| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| 4 |
|
| 5 |
{ |
| 6 |
package Test::Form; |
| 7 |
use HTML::FormHandler::Moose; |
| 8 |
extends 'HTML::FormHandler'; |
| 9 |
|
| 10 |
has_field 'foo' => ( required => 1, required_message => "You must supply a FOO!" ); |
| 11 |
has_field 'bar' => ( required => 1, messages => { required => 'You must supply a BAR!' } ); |
| 12 |
has_field 'baz'; |
| 13 |
} |
| 14 |
|
| 15 |
my $form = Test::Form->new; |
| 16 |
|
| 17 |
$form->process( params => {} ); |
| 18 |
$form->process( params => { baz => 'True' } ); |
| 19 |
|
| 20 |
my @errors = $form->errors; |
| 21 |
is( scalar @errors, 2, 'right number of errors' ); |
| 22 |
is( $errors[0], 'You must supply a FOO!', 'right message for foo' ); |
| 23 |
is( $errors[1], 'You must supply a BAR!', 'right message for bar' ); |
| 24 |
|
| 25 |
done_testing; |