File: req_message.t

package info (click to toggle)
libhtml-formhandler-perl 0.40057-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,320 kB
  • ctags: 685
  • sloc: perl: 8,849; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 686 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings;
use Test::More;

{
    package Test::Form;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler';

    has_field 'foo' => ( required => 1, required_message => "You must supply a FOO!" );
    has_field 'bar' => ( required => 1, messages => { required => 'You must supply a BAR!' } );
    has_field 'baz';
}

my $form = Test::Form->new;

$form->process( params => {} );
$form->process( params => { baz => 'True' } );

my @errors = $form->errors;
is( scalar @errors, 2, 'right number of errors' );
is( $errors[0], 'You must supply a FOO!', 'right message for foo' );
is( $errors[1], 'You must supply a BAR!', 'right message for bar' );

done_testing;