Concept Flow - Validation error details
Receive API Request
Validate Input Data
Process Request
Send Success
End
The API receives a request, checks the input data, and either processes it or returns detailed validation errors.
POST /api/users
{
"email": "bademail",
"age": -5
}| Step | Validation Check | Condition | Result | Error Detail Collected |
|---|---|---|---|---|
| 1 | Check email format | "bademail" contains '@' | False | "email": "Invalid email format" |
| 2 | Check age >= 0 | -5 >= 0 | False | "age": "Must be non-negative" |
| 3 | All validations passed? | No | No | Return errors collected |
| 4 | Send response | Errors exist | Send 400 Bad Request | {"email": "Invalid email format", "age": "Must be non-negative"} |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| errors | {} | {"email": "Invalid email format"} | {"email": "Invalid email format", "age": "Must be non-negative"} | {"email": "Invalid email format", "age": "Must be non-negative"} |
Validation error details in REST API: - Receive input data - Check each field for correctness - Collect all errors found - Return errors in response with 400 status - Helps client fix all issues at once