karenetheridge / JSON-Schema-Modern

Validate data against a schema using a JSON Schema
https://metacpan.org/release/JSON-Schema-Modern/
Other
10 stars 1 forks source link

optionally support bigints and bignums #10

Closed karenetheridge closed 2 years ago

karenetheridge commented 4 years ago

Cpanel::JSON::XS has a 'get_allow_bignum' option which inflates very large numbers into Math::BigInt or Math::BigFloat objects. If desired, we should support validating integers and numbers using this.

karenetheridge commented 4 years ago

any interesting tests I come up with should be added to the test suite - see https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues/378

karenetheridge commented 4 years ago

This should fix the issues I'm seeing on this smoker here -- http://www.cpantesters.org/cpan/report/c65fadbe-a2d4-11ea-9066-e374b0ba08e8

on my box:

perl -MCpanel::JSON::XS=decode_json -MDevel::Peek -wle'my $data = decode_json(q{[ 9007199254740992, 9007199254740992.0 ]}); Dump($_) foreach @$data; print $_ foreach @$data'
SV = IV(0x7fd6180025e8) at 0x7fd6180025f8
  REFCNT = 2
  FLAGS = (IOK,pIOK)
  IV = 9007199254740992
SV = NV(0x7fd618002760) at 0x7fd618002778
  REFCNT = 2
  FLAGS = (NOK,pNOK)
  NV = 9.00719925474099e+15
9007199254740992
9.00719925474099e+15

let's see what it looks like on BinGOs's machine..

bingos commented 4 years ago

Different VM from the one that generated that report, but another 32bit Debian. Got a similar fail, so here is the output:

$ /opt/perl-5.22.4/bin/perl -MCpanel::JSON::XS=decode_json -MDevel::Peek -wle'my $data = decode_json(q{[ 9007199254740992, 9007199254740992.0 ]}); Dump($_) foreach @$data; print $_ foreach @$data'
SV = PV(0x1fb70e0) at 0x1fb6500
  REFCNT = 2
  FLAGS = (POK,pPOK)
  PV = 0x1fcbaf0 "9007199254740992"\0
  CUR = 16
  LEN = 18
SV = NV(0x1fd51fc) at 0x1fb6f90
  REFCNT = 2
  FLAGS = (NOK,pNOK)
  NV = 9.00719925474099e+15
9007199254740992
9.00719925474099e+15
karenetheridge commented 4 years ago

until I add bigint/bignum handling, I should just mark this specific test TODO if $Config{something}.

karenetheridge commented 2 years ago

This is now complete, and with version 0.537, hopefully bug free.