added: global validators, dynamic validators with arguments, new builtin type range(start-end)

This commit is contained in:
TLINDEN
2014-11-06 00:07:03 +01:00
parent ae5817dd17
commit eddbde83bd
3 changed files with 147 additions and 30 deletions

14
t/run.t
View File

@@ -56,6 +56,8 @@ my $ref = {
son => { fullname => 'text', user => 'word' },
daughter => { fullname => 'text', user => 'word' },
},
'r1' => 'range(80-90)',
};
my $cfg = {
@@ -118,6 +120,8 @@ my $cfg = {
son => { fullname => 'Bart Simpson', user => 'bart' },
daughter => { fullname => 'Lisa Simpson', user => 'lisa' },
},
'r1' => 85,
};
my $v = new_ok('Data::Validate::Struct', [ $ref ]);
@@ -314,12 +318,19 @@ my @failure = (
errors => 1,
},
{
cfg => 100,
type => 'range(200-1000)',
descr => 'value outside dynamic range',
errors => 1,
},
);
foreach my $test (@failure) {
my $ref = { v => $test->{type} };
my $cfg = { v => $test->{cfg} };
my $v = new Data::Validate::Struct($ref);
my $v = Data::Validate::Struct->new($ref);
#$v->debug();
my $result = $v->validate($cfg);
my $descr = encode('UTF-8',
@@ -334,6 +345,7 @@ foreach my $test (@failure) {
}
}
# clean old object
undef $v;
$v = Data::Validate::Struct->new({