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

Is there an option to set strict mode to be true ? #145

Open
mfoq opened this issue Nov 28, 2024 · 2 comments
Open

Is there an option to set strict mode to be true ? #145

mfoq opened this issue Nov 28, 2024 · 2 comments

Comments

@mfoq
Copy link

mfoq commented Nov 28, 2024

in my case, only the main keys have been validated the inner keys (nested ones are not) so I think if there's an option to setthe strict mode to be true so the inner keys are validated :

schema :

{
   "$schema": "http://json-schema.org/draft-07/schema",
   "$id": "https://example.com/person.schema.json",
   "type":"array",
   "items": {
     "type": "object",
     "properties": {
       "attribute": {
         "type": "object",
         "properties": {
           "attribute": {
             "type": "object",
             "properties": {
               "name": {
                 "type": "string"
               },
               "type":{
                 "type":"integer"
               },
               "localizations": {
                 "type": "array",
                 "items": {
                   "type": "object",
                   "properties": {
                     "lang": {
                       "type": "string"
                     },
                     "translation": {
                       "type": "string"
                     }
                   },
                   "required": ["lang", "translation"]
                 }
               },
               "questions": {
                 "type": "array",
                 "items": {
                   "type": "object",
                   "properties": {
                     "text": {
                       "type": "string"
                     },
                     "localizations": {
                       "type": "array",
                       "items": {
                         "type": "object",
                         "properties": {
                           "lang": {
                             "type": "string"
                           },
                           "translation": {
                             "type": "string"
                           }
                         },
                         "required": ["lang", "translation"]
                       }
                     }
                   },
                   "required": ["text", "localizations"]
                 }
               },
               "sub-attributes": {
                 "type": "array",
                 "items": {
                   "type": "object",
                   "properties": {
                     "name": {
                       "type": "string"
                     },
                     "localizations": {
                       "type": "array",
                       "items": {
                         "type": "object",
                         "properties": {
                           "lang": {
                             "type": "string"
                           },
                           "translation": {
                             "type": "string"
                           }
                         },
                         "required": ["lang", "translation"]
                       }
                     },
                     "questions": {
                       "type": "array",
                       "items": {
                         "type": "object",
                         "properties": {
                           "text": {
                             "type": "string"
                           },
                           "localizations": {
                             "type": "array",
                             "items": {
                               "type": "object",
                               "properties": {
                                 "lang": {
                                   "type": "string"
                                 },
                                 "translation": {
                                   "type": "string"
                                 }
                               },
                               "required": ["lang", "translation"]
                             }
                           }
                         },
                         "required": ["text", "localizations"]
                       }
                     }
                   },
                   "required": ["name", "localizations", "questions"]
                 }
               }
             },
             "required": ["name", "localizations", "questions", "sub-attributes"]
           }
         },
         "required": ["name", "type","localizations", "questions", "sub-attributes"]
       }
     },
     "required": ["attribute"]
   }
}

only name, type, localizations, questions, sub-attributes, being validated if they are empty or not without checking their data types

@sorinsarca
Copy link
Member

what data are you trying to validate?

@mfoq
Copy link
Author

mfoq commented Nov 30, 2024

hi @sorinsarca thank you for your reply, this is sample of data that I want to validate:

[
        {
        "attribute":{
                "name": "Engagement",
                "type" : "GDRSFSEF",
                "localizations": [
                    {
                        "lang": "ar",
                        "translation": "الاندماج الوظيفي"
                    }
                ],
                "questions": [
                    {
                        "text": "I am very likely to recommend my organization as a place to work to my friends",
                        "localizations": [
                            {
                                "lang": "ar",
                                "translation": "أوصي بمؤسستي وأنصح أصدقائي بها كمكان للعمل"
                            }
                        ]
                    }
                ],
                "sub-attributes": [
                {
                    "name": "Belonging",
                    "type": 3,
                    "localizations": [
                    {
                        "lang": "ar",
                        "translation": "الانتماء"
                    }
                    ],
                    "questions": [
                    {
                        "text": "I feel I belong to my organization",
                        "localizations": [
                        {
                            "lang": "ar",
                            "translation": "أشعر بالإنتماء لمؤسستي"
                        }
                        ]
                    }
                    ]
                },
                {
                    "name": "Pride",
                    "type": 3,
                    "localizations": [
                    {
                        "lang": "ar",
                        "translation": "الفخر"
                    }
                    ],
                    "questions": [
                    {
                        "text": "I am proud for being part of my organization",
                        "localizations": [
                        {
                            "lang": "ar",
                            "translation": "أنا فخور لكوني جزء من مؤسستي"
                        }
                        ]
                    }
                    ]
                },
                {
                    "name": "Satisfaction",
                    "type": 3,
                    "localizations": [
                    {
                        "lang": "ar",
                        "translation": "الرضى"
                    }
                    ],
                    "questions": [
                    {
                        "text": "I am satisfied with my organization",
                        "localizations": [
                        {
                            "lang": "ar",
                            "translation": "أشعر بالرضى بمؤسستي"
                        }
                        ]
                    }
                    ]
                }
                ]
            }
        }
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants