Validate: Fix referencing & merging already compiled schemas
This commit is contained in:
parent
65cf842500
commit
a7bfe146b1
2 changed files with 16 additions and 1 deletions
|
|
@ -275,6 +275,14 @@ t { weburl => 1}, $_, $_ for (
|
|||
'https://blicky.net/?#Who\'d%20ever%22makeaurl_like-this/!idont.know',
|
||||
);
|
||||
|
||||
# Merging nested schemas
|
||||
my $pa = FU::Validate->compile({ regex => '^a' });
|
||||
my $pz = FU::Validate->compile({ regex => 'z$' });
|
||||
my $com = FU::Validate->compile([ elems => $pa, elems => $pz ]);
|
||||
is_deeply $com->validate(['axz']), ['axz'];
|
||||
ok !eval { $com->validate(['bz', 'axz', 'ax']) };
|
||||
is [$@->errors]->[0], "[0]: failed validation 'regex'";
|
||||
is [$@->errors]->[1], "[2]: failed validation 'regex'";
|
||||
|
||||
# Things that should fail
|
||||
ok !eval { FU::Validate->compile({ recursive => 1 }, { recursive => { recursive => 1 } }); 1 }, 'recursive';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue