I have created a JSON schema to register multiple users at once. Each object in the JSON should contain at least one property for registration. Here is the schema I am using:
{
"description":"Schema definition for user registration request",
"type":"object",
"properties":{
"registerRequests":{
"type":"array",
"items":{
"type":"object",
"properties":{
"user":{
"type":"object",
"properties":{
"age":{
"type":"integer",
"optional":true,
"minimum":1950,
"maximum":2100
},
"name":{
"type":"object",
"properties":{
"code":{
"type":"string",
"pattern":"^[\\w\\s!@#\\$%&\\-\\+=;:'\",\\.\\?\\(\\)\\\\/]{1,500}$"
},
"Desc":{
"type":"string",
"pattern":"^[\\w\\s!@#\\$%&\\-\\+=;:'\",\\.\\?\\(\\)\\\\/]{1,500}$"
}
},
"optional":true
}
}
}
}
}
}
},
"additionalProperties":false
}
When sending a request to register two users, each object must include at least one property as shown below:
{
"registerRequests": [
{
"user": {
"age": "25",
"Desc": "Test"
}
},
{
"user": {
"age": "20"
}
}
]
}
If I try to add a third object with no properties, I want to restrict it within the JSON itself. Is there an attribute similar to 'pattern' or 'optional' that can enforce this requirement?