jhthorsen / jhthorsen/json-validator
boolen coercion doesn't work well with perl v5.40 and above
Open
bug
help wanted
- Dominant language
- Perl
- Stars
- 60
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
Here's a script that claims a valid object is invalid. As you can see, I'm using perl's native booleans:
```perl
use v5.42;
use JSON::Validator;
my $jv = JSON::Validator->new;
$jv->coerce('booleans');
$jv->schema({
type => 'object',
properties => {
v => {
type => 'boolean',
const => true,
}
}
});
my @errors = $jv->validate({ v => 1 });
say foreach @errors;
say 'ALL OK' if ! @errors;
```
Same thing happens if I replace `const => true` with `enum => [true]`.
Also `true` doesn't validate against `const => true`, when booleans are coerced.
Contributor guide
Assessment
This issue has not been assessed yet.