next-safe-action Validation Errors
Two Sources of Validation Errors
- Schema validation — automatic when input doesn't match
.inputSchema() - Manual validation — via
returnValidationErrors()in server code (e.g., "email already taken")
Both produce the same error structure on the client.
Default Error Shape (Formatted)
Mirrors the schema structure with _errors arrays at each level:
returnValidationErrors
Throws a ActionServerValidationError that the framework catches and returns as result.validationErrors. It never returns — it always throws.
For expected non-validation errors ("out of stock", "not found"), the sibling helper
returnServerError(payload)works the same way (throws internally, never returns) but setsresult.serverErrorto the typed payload, bypassinghandleServerError. See the safe-action-client skill.
Root-Level Errors
Use _errors at the top level for form-wide errors:
Supporting Docs
- Custom validation errors and returnValidationErrors patterns
- Formatted vs flattened shapes, per-action override


