Hello community,
here is the log from the commit of package perl-JSON-Validator for
openSUSE:Factory checked in at 2020-03-27 21:58:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-JSON-Validator (Old)
and /work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-JSON-Validator"
Fri Mar 27 21:58:40 2020 rev:18 rq:788941 version:3.25
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-JSON-Validator/perl-JSON-Validator.changes
2020-03-11 18:52:29.099598117 +0100
+++
/work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.3160/perl-JSON-Validator.changes
2020-03-27 22:00:20.974899275 +0100
@@ -1,0 +2,14 @@
+Thu Mar 26 03:08:02 UTC 2020 - <[email protected]>
+
+- updated to 3.25
+ see /usr/share/doc/packages/perl-JSON-Validator/Changes
+
+ 3.25 2020-03-26T07:42:16+0900
+ - Made "additionalProperties" error message less confusing
+ - Add support for "items" and "contains" can be defined-but-false #207
+ Contributor: Karen Etheridge
+ - Respect "items" when combined with "contains" #207
+ Contributor: Karen Etheridge
+ - Require Sereal::Encoder 4.00 to speed up data_checksum()
+
+-------------------------------------------------------------------
Old:
----
JSON-Validator-3.24.tar.gz
New:
----
JSON-Validator-3.25.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-JSON-Validator.spec ++++++
--- /var/tmp/diff_new_pack.SHxrW2/_old 2020-03-27 22:00:23.162900547 +0100
+++ /var/tmp/diff_new_pack.SHxrW2/_new 2020-03-27 22:00:23.166900550 +0100
@@ -17,7 +17,7 @@
Name: perl-JSON-Validator
-Version: 3.24
+Version: 3.25
Release: 0
%define cpan_name JSON-Validator
Summary: Validate data against a JSON schema
++++++ JSON-Validator-3.24.tar.gz -> JSON-Validator-3.25.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/Changes
new/JSON-Validator-3.25/Changes
--- old/JSON-Validator-3.24/Changes 2020-03-03 07:46:39.000000000 +0100
+++ new/JSON-Validator-3.25/Changes 2020-03-25 23:42:16.000000000 +0100
@@ -1,5 +1,13 @@
Revision history for perl distribution JSON-Validator
+3.25 2020-03-26T07:42:16+0900
+ - Made "additionalProperties" error message less confusing
+ - Add support for "items" and "contains" can be defined-but-false #207
+ Contributor: Karen Etheridge
+ - Respect "items" when combined with "contains" #207
+ Contributor: Karen Etheridge
+ - Require Sereal::Encoder 4.00 to speed up data_checksum()
+
3.24 2020-03-03T15:46:39+0900
- Optimize checksum generation #202
Contributor: Ere Maijala
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/META.json
new/JSON-Validator-3.25/META.json
--- old/JSON-Validator-3.24/META.json 2020-03-03 07:46:40.000000000 +0100
+++ new/JSON-Validator-3.25/META.json 2020-03-25 23:42:18.000000000 +0100
@@ -63,6 +63,6 @@
},
"x_IRC" : "irc://irc.freenode.net/#mojo"
},
- "version" : "3.24",
+ "version" : "3.25",
"x_serialization_backend" : "JSON::PP version 4.02"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/META.yml
new/JSON-Validator-3.25/META.yml
--- old/JSON-Validator-3.24/META.yml 2020-03-03 07:46:40.000000000 +0100
+++ new/JSON-Validator-3.25/META.yml 2020-03-25 23:42:17.000000000 +0100
@@ -32,5 +32,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.24'
+version: '3.25'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/lib/JSON/Validator/Error.pm
new/JSON-Validator-3.25/lib/JSON/Validator/Error.pm
--- old/JSON-Validator-3.24/lib/JSON/Validator/Error.pm 2020-02-19
01:53:57.000000000 +0100
+++ new/JSON-Validator-3.25/lib/JSON/Validator/Error.pm 2020-03-25
23:33:58.000000000 +0100
@@ -11,6 +11,7 @@
maxItems => 'Too many items: %3/%4.',
minItems => 'Not enough items: %3/%4.',
uniqueItems => 'Unique items required.',
+ contains => 'No items contained.',
},
const => {const => 'Does not match const: %3.'},
enum => {enum => 'Not in enum list: %3.'},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/lib/JSON/Validator/Util.pm
new/JSON-Validator-3.25/lib/JSON/Validator/Util.pm
--- old/JSON-Validator-3.24/lib/JSON/Validator/Util.pm 2020-03-03
07:36:29.000000000 +0100
+++ new/JSON-Validator-3.25/lib/JSON/Validator/Util.pm 2020-03-25
23:42:08.000000000 +0100
@@ -12,13 +12,15 @@
use Scalar::Util 'blessed';
use YAML::XS;
+use constant SEREAL_SUPPORT => !$ENV{JSON_VALIDATOR_NO_SEREAL}
+ && eval 'use Sereal::Encoder 4.00;1';
+
our @EXPORT_OK
= qw(E data_checksum data_section data_type is_type schema_extract
json_pointer prefix_errors schema_type);
sub E { JSON::Validator::Error->new(@_) }
-my $serializer
- = eval 'use Sereal::Encoder;1' ? \&_sereal_encode : \&YAML::XS::Dump;
+my $serializer = SEREAL_SUPPORT ? \&_sereal_encode : \&YAML::XS::Dump;
sub data_checksum {
return Mojo::Util::md5_sum(
@@ -133,9 +135,11 @@
return _guessed_right(object => $_[1])
if defined $_[0]->{maxProperties}
or defined $_[0]->{minProperties};
- return _guessed_right(array => $_[1]) if $_[0]->{additionalItems};
- return _guessed_right(array => $_[1]) if $_[0]->{items};
+
+ # additionalItems is intentionally omitted - it requires 'items' to take
effect
+ return _guessed_right(array => $_[1]) if defined $_[0]->{items};
return _guessed_right(array => $_[1]) if $_[0]->{uniqueItems};
+ return _guessed_right(array => $_[1]) if defined $_[0]->{contains};
return _guessed_right(array => $_[1])
if defined $_[0]->{maxItems}
or defined $_[0]->{minItems};
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/lib/JSON/Validator.pm
new/JSON-Validator-3.25/lib/JSON/Validator.pm
--- old/JSON-Validator-3.24/lib/JSON/Validator.pm 2020-03-03
07:46:39.000000000 +0100
+++ new/JSON-Validator-3.25/lib/JSON/Validator.pm 2020-03-25
23:42:16.000000000 +0100
@@ -24,7 +24,7 @@
use constant SPECIFICATION_URL => 'http://json-schema.org/draft-04/schema#';
use constant YAML_SUPPORT => eval 'use YAML::XS 0.67;1';
-our $VERSION = '3.24';
+our $VERSION = '3.25';
our @EXPORT_OK = qw(joi validate_json);
my $BUNDLED_CACHE_DIR = path(path(__FILE__)->dirname, qw(Validator cache));
@@ -779,15 +779,17 @@
}
}
- if ($schema->{contains}) {
+ if (exists $schema->{contains}) {
my @e;
for my $i (0 .. @$data - 1) {
my @tmp = $self->_validate($data->[$i], "$path/$i", $schema->{contains});
push @e, \@tmp if @tmp;
}
push @errors, map {@$_} @e if @e >= @$data;
+ push @errors, E $path, [array => 'contains'] if not @$data;
}
- elsif (ref $schema->{items} eq 'ARRAY') {
+
+ if (ref $schema->{items} eq 'ARRAY') {
my $additional_items = $schema->{additionalItems} // {type => 'any'};
my @rules = @{$schema->{items}};
@@ -929,7 +931,7 @@
}
elsif (my @k = grep { !$rules{$_} } @dkeys) {
local $" = ', ';
- return E $path, [object => additionalProperties => join '/', @k];
+ return E $path, [object => additionalProperties => join ', ', sort @k];
}
for my $k (sort { $a cmp $b } uniq @{$schema->{required} || []}) {
@@ -1140,6 +1142,23 @@
=back
+=head2 Optional modules
+
+=over 2
+
+=item * Sereal::Encoder
+
+Installing L<Sereal::Encoder> v4.00 (or later) will make
+L<JSON::Validator::Util/data_checksum> significantly faster. This function is
+used both when parsing schemas and validating data.
+
+=item * Format validators
+
+See the documentation in L<JSON::Validator::Formats> for other optional modules
+to do validation of specific "format", such as "hostname", "ipv4" and others.
+
+=back
+
=head1 ERROR OBJECT
The methods L</validate> and the function L</validate_json> returns a list of
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/t/jv-array.t
new/JSON-Validator-3.25/t/jv-array.t
--- old/JSON-Validator-3.24/t/jv-array.t 2020-02-12 01:17:35.000000000
+0100
+++ new/JSON-Validator-3.25/t/jv-array.t 2020-03-25 23:33:58.000000000
+0100
@@ -98,4 +98,27 @@
},
E('/2', 'Should not match.');
+validate_ok [], {type => 'array', contains => {const => 'foo'}},
+ E('/', 'No items contained.');
+
+validate_ok [1], {contains => {const => 'foo'}},
+ E('/0', 'Does not match const: "foo".');
+
+validate_ok [1], {items => {not => {}}}, E('/0', 'Should not match.');
+validate_ok [1], {items => false}, E('/0', 'Should not match.');
+
+validate_ok [1, 2], {contains => {not => {}}}, E('/0', 'Should not match.'),
+ E('/1', 'Should not match.');
+
+validate_ok [1, 2], {contains => false}, E('/0', 'Should not match.'),
+ E('/1', 'Should not match.');
+
+validate_ok [1, 'hello'],
+ {contains => {const => 1}, items => {type => 'number'}},
+ E('/1', 'Expected number - got string.');
+
+validate_ok [1, 'hello'],
+ {contains => {const => 1}, items => [{type => 'string'}]},
+ E('/0', 'Expected string - got number.');
+
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/t/jv-object.t
new/JSON-Validator-3.25/t/jv-object.t
--- old/JSON-Validator-3.24/t/jv-object.t 2020-03-03 07:35:36.000000000
+0100
+++ new/JSON-Validator-3.25/t/jv-object.t 2020-03-06 01:50:43.000000000
+0100
@@ -52,9 +52,10 @@
number => 1600,
street_name => 'Pennsylvania',
street_type => 'Avenue',
- direction => 'NW'
+ direction => 'NW',
+ foo => 'nope',
},
- $schema, E('/', 'Properties not allowed: direction.');
+ $schema, E('/', 'Properties not allowed: direction, foo.');
$schema->{additionalProperties} = {type => 'string'};
validate_ok {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/JSON-Validator-3.24/t/util.t
new/JSON-Validator-3.25/t/util.t
--- old/JSON-Validator-3.24/t/util.t 2020-03-03 07:28:36.000000000 +0100
+++ new/JSON-Validator-3.25/t/util.t 2020-03-25 23:33:59.000000000 +0100
@@ -54,8 +54,8 @@
is schema_type({cannot => 'guess'}), '', 'schema_type no idea';
subtest 'data_checksum with Sereal::Encoder' => sub {
- plan skip_all => 'Sereal::Encoder not installed'
- unless eval 'use Sereal::Encoder;1';
+ plan skip_all => 'Sereal::Encoder 4.00+ not installed'
+ unless JSON::Validator::Util->SEREAL_SUPPORT;
my $d_hash = {foo => {}, bar => {}};
my $d_hash2 = {bar => {}, foo => {}};