File: deep-mixed-ref.t

package info (click to toggle)
libjson-validator-perl 5.14%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,160 kB
  • sloc: perl: 3,015; makefile: 14
file content (19 lines) | stat: -rw-r--r-- 649 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use Mojo::Base -strict;
use JSON::Validator;
use Mojo::File 'path';
use Test::More;

my $workdir = path(__FILE__)->dirname;
my $file    = path($workdir, 'spec', 'with-deep-mixed-ref.json');
my $jv      = JSON::Validator->new(cache_paths => [])->schema($file);
my @errors  = $jv->validate({age => 1, weight => {mass => 72, unit => 'kg'}, height => 100});
is int(@errors), 0, 'valid input';

use Mojolicious::Lite;
push @{app->static->paths}, $workdir;
$jv->ua(app->ua);
$jv->schema(app->ua->server->url->clone->path('/spec/with-relative-ref.json'));
@errors = $jv->validate({age => 'not a number'});
is int(@errors), 1, 'invalid age';

done_testing;