Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling allOf error message #495

Merged
merged 1 commit into from Jul 6, 2023

Conversation

anupama-kumari
Copy link
Contributor

@anupama-kumari anupama-kumari commented Jul 5, 2023

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
Copy link

codecov bot commented Jul 5, 2023

Codecov Report

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

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

❗ 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
@@            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 Coverage Δ
lib/json-schema/attributes/allof.rb 100.00% <100.00%> (+5.00%) ⬆️

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

@anupama-kumari anupama-kumari changed the title handling all of error message Fix issue #474: handling all of error message Jul 6, 2023
@ekohl ekohl linked an issue Jul 6, 2023 that may be closed by this pull request
@ekohl ekohl changed the title Fix issue #474: handling all of error message Handling allOf error message Jul 6, 2023
@ekohl ekohl merged commit 5dbb4df into voxpupuli:master Jul 6, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allOf confusing error message
3 participants