File: constraints_factory.t

package info (click to toggle)
libdata-formvalidator-perl 4.66-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 588 kB
  • ctags: 127
  • sloc: perl: 2,756; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (4)
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 Test::More 'no_plan';

use Data::FormValidator;
use Data::FormValidator::ConstraintsFactory 'make_length_constraint';

{
    my $results = Data::FormValidator->check(
        { 
            short_enough   => 'doh', 
            too_long => "So long she's happy",
        },
        {
            required => [qw/too_long short_enough/],
            constraints => {
                too_long => make_length_constraint(5),
                short_enough => make_length_constraint(5),
            }
        }
    );

    ok($results->valid('short_enough'), 'positive test for make_length_constraint()');
    ok(! $results->valid('too_long'),'negative test for make_length_constraint()');

}