Validation
API validation rejects malformed shape and invalid fields.
What it is
API validation rejects malformed shape and invalid fields.
When to use it
Validate type, size, allowlists, and required values before business checks.
Syntax
Accept: application/json
// Validation failures conventionally return 422 in Laravel.Example
{
"message":"The given data was invalid.",
"errors":{"amount_cents":["The amount cents must be at least 1."]}
}Common mistakes
Validation is not authorization; unsupported content type and malformed JSON need separate handling.