voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 241 forks source link

Integer as string should be defined as string #497

Closed mohanapriya2308 closed 11 months ago

mohanapriya2308 commented 11 months ago

Fix for #475

parse_data parses integer string also to integers. This breaks when integer string is expected to be string. To fix this, introduced new param parse_integer when set to false, integers are not parsed.

Before JSON::Validator.fully_validate({type: "string"}, "123") => ["The property '#/' of type integer did not match the following type: string in schema"]

After JSON::Validator.fully_validate({type: "string"}, "123", {"parse_integer" => false) => []

codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (5dbb4df) 90.08% compared to head (7d04f4f) 90.08%.

:exclamation: Current head 7d04f4f differs from pull request most recent head c9baeef. Consider uploading reports for the commit c9baeef to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #497 +/- ## ======================================= Coverage 90.08% 90.08% ======================================= Files 76 76 Lines 1583 1584 +1 ======================================= + Hits 1426 1427 +1 Misses 157 157 ``` | [Impacted Files](https://app.codecov.io/gh/voxpupuli/json-schema/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli) | Coverage Δ | | |---|---|---| | [lib/json-schema/validator.rb](https://app.codecov.io/gh/voxpupuli/json-schema/pull/497?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli#diff-bGliL2pzb24tc2NoZW1hL3ZhbGlkYXRvci5yYg==) | `85.28% <100.00%> (+0.04%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

bastelfreak commented 11 months ago

@mohanapriya2308 thanks for the fix!