Bird
0
0

Which of the following is a correct JSON snippet for validation error details for a missing 'email' field?

easy📝 Syntax Q3 of 15
Rest API - Error Handling
Which of the following is a correct JSON snippet for validation error details for a missing 'email' field?
A{"errors": {"email": "This field is required."}}
B{"error": "email is missing"}
C{"message": "email missing"}
D{"email_error": true}
Step-by-Step Solution
Solution:
  1. Step 1: Check JSON structure for validation errors

    Standard practice is to use an 'errors' object with field names as keys and messages as values.
  2. Step 2: Match the correct format

    {"errors": {"email": "This field is required."}} matches this pattern exactly with 'email' as key and message as value.
  3. Final Answer:

    {"errors": {"email": "This field is required."}} -> Option A
  4. Quick Check:

    Validation error JSON = errors object with field keys [OK]
Quick Trick: Use 'errors' object with field names as keys [OK]
Common Mistakes:
  • Using generic 'error' or 'message' keys without field names
  • Incorrect JSON structure without nested errors object
  • Using boolean flags instead of messages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes