5 1_validate_12_change.t - Test CGI::Ex::Validate's ability to modify form fields
10 use Test::More tests => 10;
13 use_ok('CGI::Ex::Validate');
16 sub validate { scalar CGI::Ex::Validate::validate(@_) }
19 ###----------------------------------------------------------------###
24 replace => 's/[^\d]//g',
29 foo => '123-456-7890',
31 ok(! $e, "Didn't get error");
35 key1 => 'Bu-nch @of characte#rs^',
36 key2 => '123 456 7890',
43 replace => 's/[^\s\w]//g',
47 $e = validate($form, $v);
49 is($form->{'key1'}, 'Bunch of characters', "key1 updated");
53 replace => 's/(\d{3})\D*(\d{3})\D*(\d{4})/($1) $2-$3/g',
57 $e = validate($form, $v);
59 is($form->{'key2'}, '(123) 456-7890', "Phone updated");
68 $e = validate($form, $v);
70 is($form->{'key2'}, '', "All replaced");
77 $e = validate($form, $v);
79 is($form->{'key3'}, '23', "Non-global is fine");