X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=t%2F1_validate_12_change.t;fp=t%2F1_validate_12_change.t;h=3d695a9f2dc41f152fe56ff5e2539258138aeef2;hp=ef270e2b47a8f667620712675494fbd888aaad99;hb=febed4ec71f803b083c3e61b82b9464e9bfb0992;hpb=ed00221d27dfab1e82ec2ea040ab4c399a91c545 diff --git a/t/1_validate_12_change.t b/t/1_validate_12_change.t index ef270e2..3d695a9 100644 --- a/t/1_validate_12_change.t +++ b/t/1_validate_12_change.t @@ -7,7 +7,7 @@ =cut use strict; -use Test::More tests => 5; +use Test::More tests => 10; use strict; use_ok('CGI::Ex::Validate'); @@ -34,6 +34,7 @@ ok(! $e, "Didn't get error"); my $form = { key1 => 'Bu-nch @of characte#rs^', key2 => '123 456 7890', + key3 => '123', }; @@ -44,7 +45,8 @@ $v = { }; $e = validate($form, $v); -ok(! $e && $form->{key1} eq 'Bunch of characters', "No error and key1 updated"); +ok(! $e, "No error"); +is($form->{'key1'}, 'Bunch of characters', "key1 updated"); $v = { key2 => { @@ -53,7 +55,8 @@ $v = { }; $e = validate($form, $v); -ok(! $e && $form->{key2} eq '(123) 456-7890', "No error and phone updated"); +ok(! $e, "No error"); +is($form->{'key2'}, '(123) 456-7890', "Phone updated"); $v = { key2 => { @@ -63,5 +66,14 @@ $v = { }; $e = validate($form, $v); -ok($e && $form->{key2} eq '', "Error with all replaced"); +ok($e, "Error"); +is($form->{'key2'}, '', "All replaced"); +$v = { + key3 => { + replace => 's/\d//', + }, +}; +$e = validate($form, $v); +ok(! $e, "No error"); +is($form->{'key3'}, '23', "Non-global is fine");