Skip to content

JSON schema validation in greater depths #11

@otsakir

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"
      },
...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions