File: constraints_builtin.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 (29 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl 

use Test::More qw/no_plan/;
use strict;

use Data::FormValidator;

my $input_profile = {
    required => [ qw( number_field ) ],
    constraints => {
        number_field => {
            name       => 'number',
            constraint => qr/^\d+$/,
        }
    } 
};

my $input_hashref = {
    number_field => 0,
};

my $results;
eval{
    $results = Data::FormValidator->check($input_hashref, $input_profile);
};

ok(!$@, 'survived validate');

is($results->valid->{number_field},0, 'using 0 in a constraint regexp works');