File: 16_cgi_object.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 (32 lines) | stat: -rw-r--r-- 621 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
26
27
28
29
30
31
32
# This script tests whether a CGI.pm object can be used to provide the input data
# Mark Stosberg 02/16/03 

use strict;
use lib ('.','../t');

$^W = 1;

use Test::More tests => 2;

my $q;
eval {
	use CGI;
	$q = CGI->new({ my_zipcode_field => 'big brown' });
};
ok(not $@);

use Data::FormValidator;

my $input_profile = {
	required => ['my_zipcode_field'],
};

my $validator = new Data::FormValidator({default => $input_profile});

my ($valids, $missings, $invalids, $unknowns);
eval{
  ($valids, $missings, $invalids, $unknowns) = $validator->validate($q, 'default');
};

is($valids->{my_zipcode_field}, 'big brown');