Each validation error should be clearly identified with field and message.
Step 2: Analyze options
{"error": {"code": 422, "message": "Validation failed", "fieldErrors": [{"field": "email", "message": "Invalid format"}, {"field": "password", "message": "Too short"}]}} uses an array of objects with field and message, which is clear and extensible.
Step 3: Evaluate other options
{"error": {"code": 422, "message": "Validation failed", "fields": {"email": "Invalid format", "password": "Too short"}}} uses a map but lacks message structure; C and D use strings that are less structured.
Final Answer:
{"error": {"code": 422, "message": "Validation failed", "fieldErrors": [{"field": "email", "message": "Invalid format"}, {"field": "password", "message": "Too short"}]}} provides a structured list of field errors.
Quick Check:
Is the structure clear and extensible? Yes. [OK]
Quick Trick:Use array of objects for multiple field errors [OK]
Common Mistakes:
Using plain strings instead of structured arrays
Not associating messages with specific fields
Using ambiguous keys like 'details' without structure
Master "Error Handling" in Rest API
9 interactive learning modes - each teaches the same concept differently