Wide character in die
I tried the following code which is basically what the module has as the first example with a slight change (the value of "name" is 23 which is invalid)
I got a warning on the screen:
Wide character in die
I could eliminate the warning by adding
use open qw( :std :encoding(UTF-8) );
at the top of the file.
I am not sure what should be the better way, maybe this line needs to be in the example as well.
use JSON::Schema::Validate;
use JSON ();
my $schema = {
'$schema' => 'https://json-schema.org/draft/2020-12/schema',
'$id' => 'https://example.org/s/root.json',
type => 'object',
required => [ 'name' ],
properties => {
name => { type => 'string', minLength => 1 },
next => { '$dynamicRef' => '#Node' },
},
'$dynamicAnchor' => 'Node',
additionalProperties => JSON::false,
};
my $js = JSON::Schema::Validate->new( $schema )
->compile
->content_checks
->ignore_unknown_required_vocab
->prune_unknown
->register_builtin_formats
->trace
->trace_limit(200) # 0 means unlimited
->unique_keys; # enable uniqueKeys
my $data = {
name => 23,
next => {
name => 'tail'
}
};
my $ok = $js->validate($data)
or die( $js->error );
print "ok\n";