Challenge - 5 Problems
Validation 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 validation error response?
Consider a REST API that validates user input and returns this JSON error response when the 'email' field is missing. What is the output shown to the client?
Rest API
{
"errors": {
"email": ["This field is required."]
},
"message": "Validation failed"
}Attempts:
2 left
💡 Hint
Look for the exact JSON structure that matches the validation error format.
✗ Incorrect
The API returns a JSON object with an 'errors' key containing field-specific messages and a general 'message' key. Option C matches this structure exactly.
❓ Predict Output
intermediate1:30remaining
What error message does this API return for invalid password length?
An API validates a password field and returns this JSON error response if the password is too short. What is the exact error message for the password field?
Rest API
{
"errors": {
"password": ["Password must be at least 8 characters."]
},
"message": "Validation failed"
}Attempts:
2 left
💡 Hint
Check the exact string inside the password error array.
✗ Incorrect
The error message is exactly 'Password must be at least 8 characters.' as shown in the JSON under the 'password' key.
❓ Predict Output
advanced2:30remaining
What is the output when multiple fields fail validation?
An API returns this JSON when both 'username' and 'email' fields fail validation. What is the exact JSON output?
Rest API
{
"errors": {
"username": ["Username already taken."],
"email": ["Invalid email format."]
},
"message": "Validation failed"
}Attempts:
2 left
💡 Hint
Look for the JSON where errors are arrays per field.
✗ Incorrect
The API returns errors as arrays for each field inside the 'errors' object. Option B matches this structure exactly.
❓ Predict Output
advanced1:30remaining
What error does this invalid JSON validation response cause?
This API response is missing a colon after 'errors'. What error will a JSON parser raise?
Rest API
{
"errors" {
"email": ["Required field missing."]
},
"message": "Validation failed"
}Attempts:
2 left
💡 Hint
Check the syntax near the 'errors' key.
✗ Incorrect
The missing colon after 'errors' causes a JSONDecodeError expecting a ':' delimiter.
🧠 Conceptual
expert3:00remaining
Which option correctly describes the structure of detailed validation error responses in REST APIs?
In REST API design, detailed validation error responses typically include which of the following structures?
Attempts:
2 left
💡 Hint
Think about how clients identify which fields failed validation.
✗ Incorrect
The standard pattern is to have a general message and an 'errors' object where each field maps to an array of error messages, allowing clients to show specific feedback.