make JSON::Validator::Util::is_bool return true when passed perl v5.36+ builtin booleans #275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR allows newer Perls' (v5.36+) builtin core booleans to be validated as booleans. It's quite a necessary change to make, as when you include the line
use v5.40in your code file, you may not replace the meaning oftrueandfalsefrom perl's core booleans just by writinguse Mojo::JSON 'true', 'false';. Therefore, it seems, core booleans need to be considered valid by all CPAN modules.I did it by modifying slightly the
JSON::Validator::Util::is_boolfunction, inspired by howJSON::PPrecently achieved the same effect.Motivation
My motivation was to resolve this bug of Mojolicious::Plugin::OpenAPI: jhthorsen/mojolicious-plugin-openapi#252
Tried my solution
I tested my modifications on a test Mojolicious website that uses Mojolicious::Plugin::OpenAPI, using both perl v5.34 (that doesn't have the builtin booleans) and perl v5.40 (that does), and the site works in both these cases.
I forgot to run
prove -vlon it, or write tests with core booleans that will run only on perl v5.40. I will do so later today or tomorrow.References