use JSV::Compiler;
my $jsv = JSV::Compiler->new;
$jsv->load_schema({
type => "object",
properties => {
foo => { type => "integer" },
bar => { type => "string" }
},
required => [ "foo" ]
});
my $vcode = $jsv->compile();
my $test_sub_txt = <<"SUB";
sub {
my \$errors = [];
$vcode;
print "\@\$errors\\n" if \@\$errors;
print "valid\n" if \@\$errors == 0;
\@\$errors == 0;
}
SUB
my $test_sub = eval $test_sub_txt;
$test_sub->({}); # foo is required
$test_sub->({ foo => 1 }); # valid
$test_sub->({ foo => 10, bar => "xyz" }); # valid
$test_sub->({ foo => 1.2, bar => "xyz" }); # foo does not look like integer number
-
Notifications
You must be signed in to change notification settings - Fork 4
jef-sure/jsv-compilator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published