mirror of
https://codeberg.org/scip/Data-Validate-Struct.git
synced 2025-12-16 20:21:02 +01:00
added: global validators, dynamic validators with arguments, new builtin type range(start-end)
This commit is contained in:
14
t/run.t
14
t/run.t
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user