voxpupuli / json-schema

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

Handling allOf error message #495

Closed anupama-kumari closed 12 months ago

anupama-kumari commented 12 months ago

user.json

{
  "type": "object",
  "required": ["user"],
  "properties": {
    "user": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "name": { "type": "string" }
          }
        },
        {
          "type": "object",
          "properties": {
            "age": { "type": "integer" }
          }
        }
      ]
    }
  }
}

Based on the sample shared, if we are having one attribute wrong we will see a particular type message , else default msg will be displayed. This is to retain current behaviour. For Example:

JSON::Validator.validate!("./user.json", user: {  name: "Jhon",  age: "1"  })
op: The property '#/user/age' of type string did not match the following type: integer in schema e026eb4f-6143-5dfc-a3df-9eb1ad1d012c
JSON::Validator.validate!("./user.json", user: {  name: 1,  age: 1  })
op: JSON::Schema::ValidationError (The property '#/user' of type object did not match all of the required schemas in schema e026eb4f-6143-5dfc-a3df-9eb1ad1d012c)
JSON::Validator.validate!("./user.json", user: {  name: 1,  age: "1"  })
op: JSON::Schema::ValidationError (The property '#/user' of type object did not match all of the required schemas in schema e026eb4f-6143-5dfc-a3df-9eb1ad1d012c)
codecov[bot] commented 12 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.07 :tada:

Comparison is base (1b801a3) 90.00% compared to head (b57e024) 90.08%.

:exclamation: Current head b57e024 differs from pull request most recent head 8c8f999. Consider uploading reports for the commit 8c8f999 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #495 +/- ## ========================================== + Coverage 90.00% 90.08% +0.07% ========================================== Files 76 76 Lines 1581 1583 +2 ========================================== + Hits 1423 1426 +3 + Misses 158 157 -1 ``` | [Impacted Files](https://app.codecov.io/gh/voxpupuli/json-schema/pull/495?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli) | Coverage Δ | | |---|---|---| | [lib/json-schema/attributes/allof.rb](https://app.codecov.io/gh/voxpupuli/json-schema/pull/495?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli#diff-bGliL2pzb24tc2NoZW1hL2F0dHJpYnV0ZXMvYWxsb2YucmI=) | `100.00% <100.00%> (+5.00%)` | :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.