safe-action-validation-errors

Return validation errors from Next.js server actions using formatted or flattened shapes.

1|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/gepetojj/umo --skill safe-action-validation-errors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-action-validation-errors
Source: https://github.com/gepetojj/umo/tree/main/.agents/skills/safe-action-validation-errors
Command: npx skills add https://github.com/gepetojj/umo --skill safe-action-validation-errors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Managing and surfacing validation errors in Next.js server actions can be error-prone and inconsistent. This Skill consolidates approaches for returnValidationErrors, formatted vs flattened shapes, custom error shapes, and optional throwValidationError behavior to improve reliability and UX.

Core Features & Use Cases

  • Centralized handling of both schema validation and manual validation errors, including field-level and form-level errors, with support for nested structures.
  • Flexible error shapes and transformation: formatted vs flattened shapes, per-action overrides, and easy UI integration.
  • Real-world use cases include forms, admin dashboards, and APIs where precise user feedback and robust error handling reduce back-and-forth support.

Quick Start

Define a Zod schema for input validation in a server action, verify business rules, and return field-level or form-level errors using returnValidationErrors.

Frequently Asked Questions about safe-action-validation-errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I return validation errors from server actions in Next.js?

Server action validation errors are handled using returnValidationErrors to provide a unified pattern for reporting field-level and form-level issues, ensuring consistent user feedback and controlled execution flow without relying on exceptions.

What is the difference between formatted and flattened error shapes in form validation?

Formatted and flattened error shapes offer different structural representations of validation issues: formatted maintains nested structures for complex fields, while flattened simplifies errors for direct UI integration and easier display mapping.

How do I handle both schema and manual validation errors in Next.js API routes?

Centralize handling by combining schema validation with manual business rule checks, then report both using returnValidationErrors to enforce strict error shapes and optional throwing for robust error management in API routes.

Can I override the error shape for specific server actions?

Yes, per-action overrides allow flexible transformation of error shapes, enabling customized mapping between formatted and flattened structures to suit specific UI integration requirements for individual forms or admin dashboards.

When should I throw validation errors instead of returning them?

Throwing validation errors is optional and suits scenarios requiring immediate execution interruption, whereas returning them via returnValidationErrors provides structured error display and controlled flow for standard form submissions and API interactions.