Skip to content

Checking value of an attribute against value of other attributes in input json data #156

@Mahesha999

Description

@Mahesha999

I am accepting information about database table schema. It contains information about table columns. Thus, as evident, those columns have name attribute of type string. However those names need not be from pre-selected names list. They can be anything input by user. Now I also want to accept the unique key for the table which can be a composite key and contain only those columns that are input by the user. In other words, the unique key can be comprised of the columns that are provided by the user in json data.

Thus technically what I need is : dynamically populated string enumeration (from input json data) which will be a type for items of array representing unique key. Thus each element of the array will be a column name.

For example below json data

"columns": 
{
    "col1": "val1",
    "col2": "val2",
    "col3": "val3"
},
"uniquelKey": ["val1","val2"]

is valid, but

"columns": 
{
    "col1": "val1",
    "col2": "val2",
    "col3": "val3"
},
"uniquelKey": ["val1","val4"]

is not valid since val4 specified in uniqueKey is not present in the columns list.
Is this achievable with current json-schema specification and implementations? I didnt found any direction in this regard.

My current json schema looks like this:

...
"attributes":
{
    "type": "array",
    "items":
    {
        "type": "object",
        "properties": 
        {
            "name": {"type": "string"},
            ...
        },
        "required": ["name",...],
        ...
    }
},
"uniqueKey": 
{
    ... ** here is where I have stuck ** ...
}
...

@fge can you please tell if this is possible or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions