tobyink / p5-json-schema

1 stars 4 forks source link

Number should accept exponential form as per JSON schema specification #19

Open tobyink opened 3 years ago

tobyink commented 3 years ago

Migrated from rt.cpan.org #122633 (status was 'open')

Requestors:

Attachments:

From raunakk@cpan.org on 2017-07-29 03:41:12 :

If we do pass floating numbers like 0.000000023, currently it fails

$result = $schema4->validate({ test => 0.000000023 }); ok $result->valid, 'number against decimal number with more than 5 decimal places' or map { diag "reason: $_" } $result->errors;

Test fails with this reason:

not ok 24 - number against decimal number with more than 5 decimal places

Failed test 'number against decimal number with more than 5 decimal places'

at t/05union.t line 181.

reason: $.test: string value found, but a number is required

as it converts into 23e-07

Refer https://tools.ietf.org/html/rfc7159#section-6

tobyink commented 3 years ago

From raunakk@cpan.org on 2017-07-29 04:07:52 :

On Fri Jul 28 23:41:12 2017, RAUNAKK wrote:

If we do pass floating numbers like 0.000000023, currently it fails

$result = $schema4->validate({ test => 0.000000023 }); ok $result->valid, 'number against decimal number with more than 5 decimal places' or map { diag "reason: $_" } $result->errors;

Test fails with this reason:

not ok 24 - number against decimal number with more than 5 decimal places

Failed test 'number against decimal number with more than 5

decimal places'

at t/05union.t line 181.

reason: $.test: string value found, but a number is required

as it converts into 23e-07

Refer https://tools.ietf.org/html/rfc7159#section-6

Forgot add PR, here is the PR url https://bitbucket.org/tobyink/p5-json-schema/pull-requests/3/

tobyink commented 3 years ago

From relequest@cpan.org on 2017-08-01 20:01:06 :

Thanks for the PR. I took on maint in hopes to upgrade to draft4, but I couldn't even make a new build because the build process is convoluted. Tobyink has stated that he won't make updates till JSON Schema is out of draft status.

I suggest you try JSON::Schema::AsType.

On Sat Jul 29 00:07:52 2017, RAUNAKK wrote:

On Fri Jul 28 23:41:12 2017, RAUNAKK wrote:

If we do pass floating numbers like 0.000000023, currently it fails

$result = $schema4->validate({ test => 0.000000023 }); ok $result->valid, 'number against decimal number with more than 5 decimal places' or map { diag "reason: $_" } $result->errors;

Test fails with this reason:

not ok 24 - number against decimal number with more than 5 decimal places

Failed test 'number against decimal number with more than 5

decimal places'

at t/05union.t line 181.

reason: $.test: string value found, but a number is required

as it converts into 23e-07

Refer https://tools.ietf.org/html/rfc7159#section-6

Forgot add PR, here is the PR url https://bitbucket.org/tobyink/p5- json-schema/pull-requests/3/