Hello community,
here is the log from the commit of package perl-JSON-Validator for
openSUSE:Factory checked in at 2020-02-10 21:56:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-JSON-Validator (Old)
and /work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-JSON-Validator"
Mon Feb 10 21:56:03 2020 rev:12 rq:773103 version:3.19
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-JSON-Validator/perl-JSON-Validator.changes
2020-01-30 09:42:19.329519689 +0100
+++
/work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.26092/perl-JSON-Validator.changes
2020-02-10 21:56:11.514282810 +0100
@@ -1,0 +2,11 @@
+Sat Feb 8 03:09:33 UTC 2020 - <[email protected]>
+
+- updated to 3.19
+ see /usr/share/doc/packages/perl-JSON-Validator/Changes
+
+ 3.19 2020-02-07T11:10:58+0900
+ - Add clearer error when more than one oneOf rule matched #184
+ Contributor: Karen Etheridge
+ - Improved validation of numeric minimum and maximum values
+
+-------------------------------------------------------------------
Old:
----
JSON-Validator-3.18.tar.gz
New:
----
JSON-Validator-3.19.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-JSON-Validator.spec ++++++
--- /var/tmp/diff_new_pack.upsAsf/_old 2020-02-10 21:56:12.022283091 +0100
+++ /var/tmp/diff_new_pack.upsAsf/_new 2020-02-10 21:56:12.026283093 +0100
@@ -17,7 +17,7 @@
Name: perl-JSON-Validator
-Version: 3.18
+Version: 3.19
Release: 0
%define cpan_name JSON-Validator
Summary: Validate data against a JSON schema
++++++ JSON-Validator-3.18.tar.gz -> JSON-Validator-3.19.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/Changes
new/JSON-Validator-3.19/Changes
--- old/JSON-Validator-3.18/Changes 2020-01-29 02:18:09.000000000 +0100
+++ new/JSON-Validator-3.19/Changes 2020-02-07 03:10:58.000000000 +0100
@@ -1,5 +1,10 @@
Revision history for perl distribution JSON-Validator
+3.19 2020-02-07T11:10:58+0900
+ - Add clearer error when more than one oneOf rule matched #184
+ Contributor: Karen Etheridge
+ - Improved validation of numeric minimum and maximum values
+
3.18 2020-01-29T10:18:09+0900
- Fix validating constants that are null or the empty string
Contributor: Karen Etheridge
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/META.json
new/JSON-Validator-3.19/META.json
--- old/JSON-Validator-3.18/META.json 2020-01-29 02:18:11.000000000 +0100
+++ new/JSON-Validator-3.19/META.json 2020-02-07 03:11:00.000000000 +0100
@@ -61,6 +61,6 @@
},
"x_IRC" : "irc://irc.freenode.net/#mojo"
},
- "version" : "3.18",
+ "version" : "3.19",
"x_serialization_backend" : "JSON::PP version 4.02"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/META.yml
new/JSON-Validator-3.19/META.yml
--- old/JSON-Validator-3.18/META.yml 2020-01-29 02:18:11.000000000 +0100
+++ new/JSON-Validator-3.19/META.yml 2020-02-07 03:10:59.000000000 +0100
@@ -30,5 +30,5 @@
homepage: https://mojolicious.org
license: http://www.opensource.org/licenses/artistic-license-2.0
repository: https://github.com/mojolicious/json-validator.git
-version: '3.18'
+version: '3.19'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/lib/JSON/Validator/Error.pm
new/JSON-Validator-3.19/lib/JSON/Validator/Error.pm
--- old/JSON-Validator-3.18/lib/JSON/Validator/Error.pm 2019-10-28
05:29:58.000000000 +0100
+++ new/JSON-Validator-3.19/lib/JSON/Validator/Error.pm 2020-02-07
03:10:29.000000000 +0100
@@ -15,6 +15,8 @@
const => {const => 'Does not match const: %3.'},
enum => {enum => 'Not in enum list: %3.'},
integer => {
+ ex_maximum => '%3 >= maximum(%4)',
+ ex_minimum => '%3 <= minimum(%4)',
maximum => '%3 > maximum(%4)',
minimum => '%3 < minimum(%4)',
multipleOf => 'Not multiple of %3.',
@@ -22,6 +24,8 @@
not => {not => 'Should not match.'},
null => {null => 'Not null.'},
number => {
+ ex_maximum => '%3 >= maximum(%4)',
+ ex_minimum => '%3 <= minimum(%4)',
maximum => '%3 > maximum(%4)',
minimum => '%3 < minimum(%4)',
multipleOf => 'Not multiple of %3.',
@@ -34,6 +38,7 @@
},
oneOf => {
all_rules_match => 'All of the oneOf rules match.',
+ n_rules_match => 'oneOf rules %3 match.',
type => '/oneOf Expected %3 - got %4.',
},
string => {
@@ -88,7 +93,7 @@
}
sub to_string { sprintf '%s: %s', $_[0]->path, $_[0]->message }
-sub TO_JSON { {message => $_[0]->message, path => $_[0]->path} }
+sub TO_JSON { {message => $_[0]->message, path => $_[0]->path} }
1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/lib/JSON/Validator/Formats.pm
new/JSON-Validator-3.19/lib/JSON/Validator/Formats.pm
--- old/JSON-Validator-3.18/lib/JSON/Validator/Formats.pm 2019-09-27
03:36:58.000000000 +0200
+++ new/JSON-Validator-3.19/lib/JSON/Validator/Formats.pm 2020-02-07
02:41:31.000000000 +0100
@@ -69,7 +69,7 @@
my @email = split /@/, $_[0], 2;
check_email(
join '@',
- Net::IDN::Encode::to_ascii($email[0] // ''),
+ Net::IDN::Encode::to_ascii($email[0] // ''),
Net::IDN::Encode::domain_to_ascii($email[1] // ''),
);
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/lib/JSON/Validator.pm
new/JSON-Validator-3.19/lib/JSON/Validator.pm
--- old/JSON-Validator-3.18/lib/JSON/Validator.pm 2020-01-29
02:18:09.000000000 +0100
+++ new/JSON-Validator-3.19/lib/JSON/Validator.pm 2020-02-07
03:10:58.000000000 +0100
@@ -23,7 +23,7 @@
use constant RECURSION_LIMIT => $ENV{JSON_VALIDATOR_RECURSION_LIMIT} || 100;
use constant SPECIFICATION_URL => 'http://json-schema.org/draft-04/schema#';
-our $VERSION = '3.18';
+our $VERSION = '3.19';
our $YAML_LOADER = eval q[use YAML::XS 0.67; YAML::XS->can('Load')]; #
internal
our @EXPORT_OK = qw(joi validate_json);
@@ -393,7 +393,7 @@
$tx = $self->ua->get($url);
$err = $tx->error && $tx->error->{message};
- confess "GET $url == $err" if DEBUG and $err;
+ confess "GET $url == $err" if DEBUG and $err;
die "[JSON::Validator] GET $url == $err" if $err;
if ($cache_path
@@ -569,11 +569,11 @@
last if !$ref or ref $ref;
$fqn = $ref =~ m!^/! ? "#$ref" : $ref;
($location, $pointer) = split /#/, $fqn, 2;
- $url = $location = _location_to_abs($location, $url);
+ $url = $location = _location_to_abs($location, $url);
$pointer = undef if length $location and !length $pointer;
$pointer = url_unescape $pointer if defined $pointer;
- $fqn = join '#', grep defined, $location, $pointer;
- $other = $self->_resolve($location);
+ $fqn = join '#', grep defined, $location, $pointer;
+ $other = $self->_resolve($location);
if (defined $pointer and length $pointer and $pointer =~ m!^/!) {
$other = Mojo::JSON::Pointer->new($other)->get($pointer)
@@ -632,21 +632,21 @@
$self->_report_schema($path || '/', $type, $schema) if REPORT;
@errors = $self->$method($to_json ? $$to_json : $_[1], $path, $schema);
$self->_report_errors($path, $type, \@errors) if REPORT;
- return @errors if @errors;
+ return @errors if @errors;
}
if (exists $schema->{const}) {
push @errors,
$self->_validate_type_const($to_json ? $$to_json : $_[1], $path,
$schema);
- $self->_report_errors($path, 'enum', \@errors) if REPORT;
- return @errors if @errors;
+ $self->_report_errors($path, 'const', \@errors) if REPORT;
+ return @errors if @errors;
}
if ($schema->{enum}) {
push @errors,
$self->_validate_type_enum($to_json ? $$to_json : $_[1], $path, $schema);
$self->_report_errors($path, 'enum', \@errors) if REPORT;
- return @errors if @errors;
+ return @errors if @errors;
}
if (my $rules = $schema->{not}) {
@@ -731,9 +731,9 @@
$self->_report_schema($path, 'oneOf', $rules) if REPORT;
local $self->{grouped} = $self->{grouped} + 1;
- my $i = 0;
+ my ($i, @passed) = (0);
for my $rule (@$rules) {
- my @e = $self->_validate($_[1], $path, $rule) or next;
+ my @e = $self->_validate($_[1], $path, $rule) or push @passed, $i and next;
my $schema_type = _guess_schema_type($rule);
push @errors, [$i, @e] and next if !$schema_type or $schema_type eq $type;
push @expected, $schema_type;
@@ -750,11 +750,59 @@
$self->_report_errors($path, 'oneOf', \@e);
}
- return if @errors + @expected + 1 == @$rules;
- my $expected = join '/', _uniq(@expected);
+ return if @passed == 1;
return E $path, [oneOf => 'all_rules_match'] unless @errors + @expected;
- return E $path, [oneOf => type => $expected => $type] unless @errors;
- return _add_path_to_error_messages(oneOf => @errors);
+ return E $path, [oneOf => 'n_rules_match', join(', ', @passed)] if @passed;
+ return _add_path_to_error_messages(oneOf => @errors) if @errors;
+ return E $path, [oneOf => type => join('/', _uniq(@expected)), $type];
+}
+
+sub _validate_number_max {
+ my ($self, $value, $path, $schema, $expected) = @_;
+ my @errors;
+
+ my $cmp_with = $schema->{exclusiveMaximum} // '';
+ if (_is_boolean($cmp_with)) {
+ push @errors, E $path,
+ [$expected => ex_maximum => $value, $schema->{maximum}]
+ unless $value < $schema->{maximum};
+ }
+ elsif (_is_number($cmp_with)) {
+ push @errors, E $path, [$expected => ex_maximum => $value, $cmp_with]
+ unless $value < $cmp_with;
+ }
+
+ if (exists $schema->{maximum}) {
+ my $cmp_with = $schema->{maximum};
+ push @errors, E $path, [$expected => maximum => $value, $cmp_with]
+ unless $value <= $cmp_with;
+ }
+
+ return @errors;
+}
+
+sub _validate_number_min {
+ my ($self, $value, $path, $schema, $expected) = @_;
+ my @errors;
+
+ my $cmp_with = $schema->{exclusiveMinimum} // '';
+ if (_is_boolean($cmp_with)) {
+ push @errors, E $path,
+ [$expected => ex_minimum => $value, $schema->{minimum}]
+ unless $value > $schema->{minimum};
+ }
+ elsif (_is_number($cmp_with)) {
+ push @errors, E $path, [$expected => ex_minimum => $value, $cmp_with]
+ unless $value > $cmp_with;
+ }
+
+ if (exists $schema->{minimum}) {
+ my $cmp_with = $schema->{minimum};
+ push @errors, E $path, [$expected => minimum => $value, $cmp_with]
+ unless $value >= $cmp_with;
+ }
+
+ return @errors;
}
sub _validate_type_enum {
@@ -852,13 +900,7 @@
sub _validate_type_boolean {
my ($self, $value, $path, $schema) = @_;
-
- # Object representing a boolean
- if (blessed $value
- and ($value->isa('JSON::PP::Boolean') or "$value" eq "1" or !$value))
- {
- return;
- }
+ return if _is_boolean($value);
# String that looks like a boolean
if (
@@ -880,7 +922,7 @@
my @errors = $self->_validate_type_number($_[1], $path, $schema, 'integer');
return @errors if @errors;
- return if $value =~ /^-?\d+$/;
+ return if $value =~ /^-?\d+$/;
return E $path, [integer => type => _guess_data_type($value)];
}
@@ -907,24 +949,14 @@
$_[1] = 0 + $value; # coerce input value
}
- if ($schema->{format}) {
- push @errors, $self->_validate_format($value, $path, $schema);
- }
- if (my $e
- = _cmp($schema->{minimum}, $value, $schema->{exclusiveMinimum}, '<'))
- {
- push @errors, E $path, [$expected => minimum => $value,
$schema->{minimum}];
- }
- if (my $e
- = _cmp($value, $schema->{maximum}, $schema->{exclusiveMaximum}, '>'))
- {
- push @errors, E $path, [$expected => maximum => $value,
$schema->{maximum}];
- }
- if (my $d = $schema->{multipleOf}) {
- if (($value / $d) =~ /\.[^0]+$/) {
- push @errors, E $path, [$expected => multipleOf => $d];
- }
- }
+ push @errors, $self->_validate_format($value, $path, $schema)
+ if $schema->{format};
+ push @errors, $self->_validate_number_max($value, $path, $schema, $expected);
+ push @errors, $self->_validate_number_min($value, $path, $schema, $expected);
+
+ my $d = $schema->{multipleOf};
+ push @errors, E $path, [$expected => multipleOf => $d]
+ if $d and ($value / $d) =~ /\.[^0]+$/;
return @errors;
}
@@ -1065,13 +1097,6 @@
return @errors;
}
-sub _cmp {
- return undef if !defined $_[0] or !defined $_[1];
- return "$_[3]=" if $_[2] and $_[0] >= $_[1];
- return $_[3] if $_[0] > $_[1];
- return "";
-}
-
# _guess_data_type($data, [{type => ...}, ...])
sub _guess_data_type {
my $ref = ref $_[0];
@@ -1126,6 +1151,11 @@
return undef;
}
+sub _is_boolean {
+ return blessed $_[0]
+ && ($_[0]->isa('JSON::PP::Boolean') || "$_[0]" eq "1" || !$_[0]);
+}
+
sub _is_number {
B::svref_2object(\$_[0])->FLAGS & (B::SVp_IOK | B::SVp_NOK)
&& 0 + $_[0] eq $_[0]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/acceptance.t
new/JSON-Validator-3.19/t/acceptance.t
--- old/JSON-Validator-3.18/t/acceptance.t 2019-01-20 23:31:14.000000000
+0100
+++ new/JSON-Validator-3.19/t/acceptance.t 2020-02-07 02:41:31.000000000
+0100
@@ -18,7 +18,7 @@
my $host_port = $t->ua->server->url->host_port;
my $test_only_re = $ENV{TEST_ONLY} || '';
-my $todo_re = join('|',
+my $todo_re = join('|',
'dependencies',
'change resolution scope - changed scope ref valid',
$ENV{TEST_ONLINE} ? () : ('remote ref'),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/coerce.t
new/JSON-Validator-3.19/t/coerce.t
--- old/JSON-Validator-3.18/t/coerce.t 2019-09-27 03:36:58.000000000 +0200
+++ new/JSON-Validator-3.19/t/coerce.t 2020-02-07 02:41:31.000000000 +0100
@@ -47,7 +47,7 @@
my $base = {type => shift};
return (
$base,
- {type => ['array', $base->{type}]},
+ {type => ['array', $base->{type}]},
{allOf => [$base]},
{anyOf => [{type => 'array'}, $base]},
{oneOf => [$base, {type => 'array'}]},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/formats.t
new/JSON-Validator-3.19/t/formats.t
--- old/JSON-Validator-3.18/t/formats.t 2019-09-27 03:36:58.000000000 +0200
+++ new/JSON-Validator-3.19/t/formats.t 2020-02-07 02:41:31.000000000 +0100
@@ -1,7 +1,7 @@
use strict;
use Test::More;
-BEGIN { use_ok ('JSON::Validator::Formats'); }
+BEGIN { use_ok('JSON::Validator::Formats'); }
ok !JSON::Validator::Formats::check_date('2019-06-11');
ok !JSON::Validator::Formats::check_email('[email protected]');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/get.t
new/JSON-Validator-3.19/t/get.t
--- old/JSON-Validator-3.18/t/get.t 2018-12-15 05:21:00.000000000 +0100
+++ new/JSON-Validator-3.19/t/get.t 2020-02-07 02:41:31.000000000 +0100
@@ -2,12 +2,10 @@
use Test::More;
use JSON::Validator;
-my $jv = JSON::Validator->new->schema(
- {
- foo => [{y => 'foo'}],
- bar => [{y => 'first'}, {y => 'second'}, {z => 'zzz'}],
- }
-);
+my $jv = JSON::Validator->new->schema({
+ foo => [{y => 'foo'}],
+ bar => [{y => 'first'}, {y => 'second'}, {z => 'zzz'}],
+});
is $jv->get('/bar/2/z'), 'zzz', 'get /bar/2/z';
is $jv->get([qw(nope 404)]), undef, 'get /nope/404';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/id-keyword-draft4.t
new/JSON-Validator-3.19/t/id-keyword-draft4.t
--- old/JSON-Validator-3.18/t/id-keyword-draft4.t 2019-01-05
04:48:15.000000000 +0100
+++ new/JSON-Validator-3.19/t/id-keyword-draft4.t 2020-02-07
02:41:31.000000000 +0100
@@ -11,7 +11,7 @@
get '/invalid-relative' => 'invalid-relative';
get '/relative-to-the-root' => 'relative-to-the-root';
-$t = Test::Mojo->new;
+$t = Test::Mojo->new;
$jv = JSON::Validator->new(ua => $t->ua);
$t->get_ok('/relative-to-the-root.json')->status_is(200);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/id-keyword-draft7.t
new/JSON-Validator-3.19/t/id-keyword-draft7.t
--- old/JSON-Validator-3.18/t/id-keyword-draft7.t 2019-01-20
11:42:12.000000000 +0100
+++ new/JSON-Validator-3.19/t/id-keyword-draft7.t 2020-02-07
02:41:31.000000000 +0100
@@ -10,7 +10,7 @@
get '/person' => 'person';
get '/invalid-relative' => 'invalid-relative';
-$t = Test::Mojo->new;
+$t = Test::Mojo->new;
$jv = JSON::Validator->new(ua => $t->ua);
eval {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/issue-103-one-of.t
new/JSON-Validator-3.19/t/issue-103-one-of.t
--- old/JSON-Validator-3.18/t/issue-103-one-of.t 2018-12-15
05:21:00.000000000 +0100
+++ new/JSON-Validator-3.19/t/issue-103-one-of.t 2020-02-07
03:10:28.000000000 +0100
@@ -7,6 +7,16 @@
E('/template', '/oneOf/0/allOf/2 Missing property.'),
E('/sym', '/oneOf/1/allOf/0 Missing property.');
+validate_ok {
+ sym => 'a',
+ expire => 'b',
+ amount => 1,
+ desc => 'foo',
+ who_id => 'c',
+ template => 'd'
+ },
+ 'data://main/example.json', E('/', 'oneOf rules 0, 1 match.');
+
done_testing;
__DATA__
@@ -14,7 +24,8 @@
{
"oneOf": [
{"$ref": "#/definitions/template_1"},
- {"$ref": "#/definitions/bar_header"}
+ {"$ref": "#/definitions/bar_header"},
+ {"type": "string"}
],
"definitions": {
"hwho":{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/issue-42-cache-control.t
new/JSON-Validator-3.19/t/issue-42-cache-control.t
--- old/JSON-Validator-3.18/t/issue-42-cache-control.t 2019-09-27
03:36:58.000000000 +0200
+++ new/JSON-Validator-3.19/t/issue-42-cache-control.t 2020-02-07
02:41:31.000000000 +0100
@@ -6,13 +6,14 @@
plan skip_all => 'TEST_ONLINE=1' unless $ENV{TEST_ONLINE};
$ENV{JSON_VALIDATOR_CACHE_PATH} = '/tmp/whatever';
-my $jv = JSON::Validator->new;
+my $jv = JSON::Validator->new;
my @old_files = get_cached_files($jv);
is $jv->cache_paths->[0], '/tmp/whatever', 'back compat env';
shift @{$jv->cache_paths};
-my $spec_url =
'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json';
+my $spec_url
+ =
'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/schemas/v2.0/schema.json';
$jv->schema($spec_url);
my @new_files = get_cached_files($jv);
ok @old_files == @new_files, 'remote file not cached in default cache dir';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/jv-array.t
new/JSON-Validator-3.19/t/jv-array.t
--- old/JSON-Validator-3.18/t/jv-array.t 2020-01-29 02:14:57.000000000
+0100
+++ new/JSON-Validator-3.19/t/jv-array.t 2020-02-07 02:41:31.000000000
+0100
@@ -4,10 +4,10 @@
use Test::More;
use t::Helper;
-my $simple = {type => 'array', items => {type => 'number'}};
-my $length = {type => 'array', minItems => 2, maxItems => 2};
+my $simple = {type => 'array', items => {type => 'number'}};
+my $length = {type => 'array', minItems => 2, maxItems => 2};
my $unique = {type => 'array', uniqueItems => 1, items => {type => 'integer'}};
-my $tuple = {
+my $tuple = {
type => 'array',
items => [
{type => 'number'},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/jv-number.t
new/JSON-Validator-3.19/t/jv-number.t
--- old/JSON-Validator-3.18/t/jv-number.t 2020-01-29 02:14:57.000000000
+0100
+++ new/JSON-Validator-3.19/t/jv-number.t 2020-02-07 03:10:29.000000000
+0100
@@ -16,7 +16,10 @@
validate_ok 1, $numeric_constant, E('/', q{Does not match const: 2.1.});
jv->coerce('numbers');
-validate_ok {mynumber => '-0.3'}, $schema;
+validate_ok {mynumber => '-0.5'}, $schema;
+validate_ok {mynumber => -0.6}, $schema, E('/mynumber', '-0.6 <
minimum(-0.5)');
+validate_ok {mynumber => '2.7'}, $schema;
+validate_ok {mynumber => '2.8'}, $schema, E('/mynumber', '2.8 > maximum(2.7)');
validate_ok {mynumber => '0.1e+1'}, $schema;
validate_ok {mynumber => '2xyz'}, $schema,
E('/mynumber', 'Expected number - got string.');
@@ -31,4 +34,12 @@
validate_ok '2.1', $numeric_constant;
validate_ok '1', $numeric_constant, E('/', q{Does not match const: 2.1.});
+for my $x ([-0.5, 2.7], [true, true]) {
+ $schema->{properties}{mynumber}{exclusiveMaximum} = $x->[1];
+ $schema->{properties}{mynumber}{exclusiveMinimum} = $x->[0];
+ validate_ok {mynumber => 2.7}, $schema, E('/mynumber', '2.7 >=
maximum(2.7)');
+ validate_ok {mynumber => -0.5}, $schema,
+ E('/mynumber', '-0.5 <= minimum(-0.5)');
+}
+
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/jv-oneof.t
new/JSON-Validator-3.19/t/jv-oneof.t
--- old/JSON-Validator-3.18/t/jv-oneof.t 2018-12-15 05:26:03.000000000
+0100
+++ new/JSON-Validator-3.19/t/jv-oneof.t 2020-02-07 03:10:28.000000000
+0100
@@ -36,4 +36,7 @@
validate_ok {x => '2015-04-21T20:30:43.000Z'}, $schema;
validate_ok {x => undef}, $schema;
+validate_ok 1, {oneOf => [{minimum => 1}, {minimum => 2}, {maximum => 3}]},
+ E('/', 'oneOf rules 0, 2 match.');
+
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/validate-json.t
new/JSON-Validator-3.19/t/validate-json.t
--- old/JSON-Validator-3.18/t/validate-json.t 2018-12-15 02:09:49.000000000
+0100
+++ new/JSON-Validator-3.19/t/validate-json.t 2020-02-07 02:41:31.000000000
+0100
@@ -6,7 +6,7 @@
{
use Mojolicious::Lite;
post '/' => sub {
- my $c = shift;
+ my $c = shift;
my @errors = validate_json $c->req->json, 'data://main/spec.json';
$c->render(status => @errors ? 400 : 200, text => "@errors");
};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.18/t/validate-recursive.t
new/JSON-Validator-3.19/t/validate-recursive.t
--- old/JSON-Validator-3.18/t/validate-recursive.t 2018-12-15
05:21:00.000000000 +0100
+++ new/JSON-Validator-3.19/t/validate-recursive.t 2020-02-07
02:41:31.000000000 +0100
@@ -6,7 +6,7 @@
{
use Mojolicious::Lite;
post '/' => sub {
- my $c = shift;
+ my $c = shift;
my @errors = validate_json $c->req->json, 'data://main/spec.json';
$c->render(status => @errors ? 400 : 200, json => \@errors);
};