8000 JSON schema validation in greater depths · Issue #11 · hishamhm/restserver · GitHub
[go: up one dir, main page]

Skip to content

JSON schema validation in greater depths #11

Open

Description

@otsakir

What if the object posted contains nested objects too:

POST /contacts

{
  name: "foo"
  age: 5
  address: {
    city: "ny",
    street: "bar 45"
  }
}

We need to augment the input_schema property and restserver.type_check() functionality to handle such cases. We could add a new schema property to the field that contains the nested validation object.

For example:

...
input_schema = {
         name = { type = "string"},
         age = { type = "number"},
         address = {type = "table", schema = {
                  city = { type = "string" },
                  street = { type = "string"}
              }
         }
         value_float = { type = "number", optional = true },
         contact = {type = "table"
      },
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0