forked from jhthorsen/json-validator
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of true/false in schema, when loaded with YAML::Syck closes
- Loading branch information
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use Mojo::Base -strict; | ||
use Test::More; | ||
use JSON::Validator; | ||
|
||
plan skip_all => $@ unless eval 'require YAML::Syck;1'; | ||
|
||
use JSON::Validator; | ||
Mojo::Util::monkey_patch('JSON::Validator' => _load_yaml => \&YAML::Syck::Load); | ||
|
||
my $validator = JSON::Validator->new->schema('data://main/yaml-syck.yml'); | ||
my @errors = $validator->validate({firstName => 'Jan Henning', lastName => 'Thorsen', age => 42}); | ||
|
||
ok $INC{'YAML/Syck.pm'}, 'YAML::Syck is loaded'; | ||
ok !$INC{'YAML/XS.pm'}, 'YAML::XS is not loaded'; | ||
is "@errors", "/: Properties not allowed: age.", "additionalProperties: false"; | ||
|
||
done_testing; | ||
|
||
__DATA__ | ||
@@ yaml-syck.yml | ||
--- | ||
type: object | ||
required: [firstName, lastName] | ||
additionalProperties: false | ||
properties: | ||
firstName: { type: string } | ||
lastName: { type: string } |