0

I am writing a JSON schema validation. I have an ID field whose values are imported from a table in SQL Server. These values are large and are frequently updated, so is there a way to dynamically connect to this table in the server and validate the JSON? Below is an example code of my schema:

{
  "type": "object",
  "required": ["employees"],
  "properties": {
    "employees": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", enum = [134,2123,3213,444,5525,6234,7532,825,9342]}
      }
    }
  }
}

In place of 'enum' I want to connect to a table so the ID values are updated when the table is updated.

Arcanesaw
  • 29
  • 4

1 Answers1

0

As Greg said, there is nothing in JSON Schema which allows you to do this.

Some implementations have created their own extensions to allow external sources. Many implementations allow custom keywords. You would have to check your documentation.

You should consider the cost of querying the database at the same time as checking structural correctness. It may be benficial to do ID checking which hits your database after you've confirmed the data is of the correct format and structure.

Relequestual
  • 11,631
  • 6
  • 47
  • 83