Challenge - 5 Problems
Schema Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this JSON schema validation?
Given this JSON schema and data, what will be the validation result?
Rest API
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer", "minimum": 0}
},
"required": ["name", "age"]
}
Data:
{
"name": "Alice",
"age": -5
}Attempts:
2 left
💡 Hint
Check the 'minimum' constraint for the 'age' property.
✗ Incorrect
The 'age' property must be an integer greater than or equal to 0. The data has age -5, which violates the minimum constraint.
🧠 Conceptual
intermediate1:30remaining
Which JSON schema keyword restricts the allowed properties in an object?
In JSON schema, which keyword limits the properties that can appear in an object to only those specified?
Attempts:
2 left
💡 Hint
It controls whether extra properties beyond those listed are allowed.
✗ Incorrect
The 'additionalProperties' keyword controls whether properties not listed in 'properties' are allowed or not.
🔧 Debug
advanced2:00remaining
Identify the error in this JSON schema snippet
What is wrong with this JSON schema snippet that defines an array?
Rest API
{
"type": "array",
"items": {
"type": "string"
},
"minItems": "2"
}Attempts:
2 left
💡 Hint
Check the data type of the value for 'minItems'.
✗ Incorrect
'minItems' expects a number, but here it is given as a string "2", which is invalid.
📝 Syntax
advanced2:00remaining
Which option correctly defines a schema for a nullable string?
You want a property that can be either a string or null. Which JSON schema snippet is correct?
Attempts:
2 left
💡 Hint
The 'type' keyword can accept an array of types.
✗ Incorrect
The correct way to allow multiple types is to use an array for 'type'. Option D is valid JSON schema syntax.
🚀 Application
expert2:30remaining
How many properties will be valid with this schema?
Given this schema, how many properties can a valid object have?
Rest API
{
"type": "object",
"properties": {
"a": {"type": "string"},
"b": {"type": "number"}
},
"additionalProperties": false
}Attempts:
2 left
💡 Hint
Check the effect of 'additionalProperties': false.
✗ Incorrect
With 'additionalProperties': false, only the properties listed under 'properties' are allowed. Here, only 'a' and 'b' are valid.