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

Required fields validation on nested objects #96

Closed
gersmann opened this issue Mar 28, 2023 · 2 comments
Closed

Required fields validation on nested objects #96

gersmann opened this issue Mar 28, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@gersmann
Copy link

gersmann commented Mar 28, 2023

Hi @bhch, thank you for supporting the 'required' attribute. I tested it on a schema, and it is still a bit spotty.

For instance:

{
   "properties":{
      "object1":{
         "type":"object",
         "properties":{
            "prop1":{
               "type":"string"
            },
            "prop2":{
               "type":"string"
            }
         },
         "required":[
            "prop1",
            "prop2"
         ],
         "additionalProperties":false
      },
      "object2":{
         "type":"object",
         "properties":{
            "prop3":{
               "type":"string"
            },
            "object3":{
               "type":"object",
               "properties":{
                  "prop4":{
                     "type":"string"
                  },
                  "prop5":{
                     "type":"string"
                  }
               },
               "required":[
                  "prop1",
                  "prop2"
               ],
               "additionalProperties":false
            }
         },
         "required":[
            "prop3",
            "object3"
         ],
         "additionalProperties":false
      }
   },
   "required":[
      "object1"
   ],
   "additionalProperties":false
}

This only marks prop3 as required, even though all properties are, but object2 is not.

@bhch bhch added the bug Something isn't working label Mar 28, 2023
@bhch
Copy link
Owner

bhch commented Mar 28, 2023

Ah, yes, I've found the cause of this issue. I'll fix it soon.

@bhch bhch closed this as completed in e03035c Mar 28, 2023
@bhch
Copy link
Owner

bhch commented Mar 28, 2023

Fix released in v2.16.1. Please update. Thanks for reporting this bug.


P.S.: The schema that you posted needs a minor correction. In object3 the required list should be ["prop4", "prop5"] (not ["prop1", "prop2"]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants