Apache-Voodoo
view release on metacpan or search on metacpan
t/Validate.t view on Meta::CPAN
time => ' 9:15:04 pm',
time_min => '9:00',
time_max => '17:00',
time_range => '12:00',
time_valid => '1:14:15 pm'
});
ok(scalar keys %{$e} == 0,'$errors is empty');
is($v->{time}, '21:15:04','good time 1');
is($v->{time_min}, '09:00:00','good time 2');
is($v->{time_max}, '17:00:00','good time 3');
is($v->{time_range},'12:00:00','good time 4');
is($v->{time_valid},'13:14:15','good time 5');
($v,$e) = $D->validate({
time => ' 19:15:04 pm',
time_min => '8:59:59',
time_max => '17:00:01',
time_range => '23:00',
time_valid => '12:14:15'
});
ok(scalar keys %{$v} == 0,'$values is empty');
ok(defined($e->{BAD_time}), 'bad time 1');
ok(defined($e->{MIN_time_min}), 'bad time 2');
ok(defined($e->{MAX_time_max}), 'bad time 3');
ok(defined($e->{MAX_time_range}), 'bad time 4');
ok(defined($e->{BAD_time_valid}), 'bad time 5');
my $B = Apache::Voodoo::Validate->new({
bit => {
type => 'bit',
required => 1
}
});
($v,$e) = $B->validate({ bit => ' 1' }); is($v->{bit},1,'good bit 1');
($v,$e) = $B->validate({ bit => '11' }); is($v->{bit},1,'good bit 2');
($v,$e) = $B->validate({ bit => 'y' }); is($v->{bit},1,'good bit 3');
($v,$e) = $B->validate({ bit => 'yEs' }); is($v->{bit},1,'good bit 4');
($v,$e) = $B->validate({ bit => 't' }); is($v->{bit},1,'good bit 5');
($v,$e) = $B->validate({ bit => 'tRuE'}); is($v->{bit},1,'good bit 6');
($v,$e) = $B->validate({ bit => ' 0' }); is($v->{bit},0,'good bit 7');
($v,$e) = $B->validate({ bit => '00' }); is($v->{bit},0,'good bit 8');
($v,$e) = $B->validate({ bit => 'n' }); is($v->{bit},0,'good bit 9');
($v,$e) = $B->validate({ bit => 'nO' }); is($v->{bit},0,'good bit a');
($v,$e) = $B->validate({ bit => 'f' }); is($v->{bit},0,'good bit b');
($v,$e) = $B->validate({ bit => 'fAlSe'}); is($v->{bit},0,'good bit c');
($v,$e) = $B->validate({bit => ''}); ok($e->{MISSING_bit},'bad bit 1');
($v,$e) = $B->validate({bit => undef}); ok($e->{MISSING_bit},'bad bit 2');
($v,$e) = $B->validate({bit => -1}); ok($e->{MISSING_bit},'bad bit 3');
($v,$e) = $B->validate({bit => 'a'}); ok($e->{MISSING_bit},'bad bit 4');
my $E;
eval {
$E = Apache::Voodoo::Validate->new({});
};
ok(ref($@) eq "Apache::Voodoo::Exception::RunTime::BadConfig",'Empty configuration throws exception 1 ');
eval {
$E = Apache::Voodoo::Validate->new();
};
ok(ref($@) eq "Apache::Voodoo::Exception::RunTime::BadConfig",'Empty configuration throws exception 2 ');
( run in 0.998 second using v1.01-cache-2.11-cpan-39bf76dae61 )