API Design · Middle · Question 9 of 75

How should validation errors for several fields be reported?

{
  "type": "https://api.example.com/errors/validation",
  "title": "Invalid request",
  "status": 400,
  "errors": [
    { "field": "email", "code": "invalid_format" },
    { "field": "age", "code": "too_small", "min": 18 }
  ]
}

Explanation

Problem Details allows extension members like errors. Codes let clients translate messages themselves.

Further reading

Problem with a question

API Design · Middle · question 9

Test yourself

Take the API Design · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz