dmkulyk/nova-validation-toast

Enhanced validation toast messages for Laravel Nova with deduplication and improved error handling

Installs: 226

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

pkg:composer/dmkulyk/nova-validation-toast

v1.0.9 2025-10-20 13:32 UTC

This package is auto-updated.

Last update: 2025-12-20 13:52:11 UTC


README

Enhanced validation toast messages for Laravel Nova with deduplication and improved error handling.

🚨 The Problem

By default, Laravel Nova shows only a generic "There was a problem submitting the form" toast message when validation fails. The actual validation error messages are only visible in the browser console, making it difficult for users to understand what went wrong.

✅ The Solution

This package intercepts Nova's error handling and displays the actual error messages directly in toast notifications. Now users can see specific validation errors like "Database operation failed" or field-specific validation messages right in the UI, without the second generic toast message.

Before (Standard Nova Behavior)

Standard Nova Message

Generic error message that doesn't help users understand what went wrong

Problem (Without Package)

Two Toast Messages

Users see both generic and specific messages, creating confusion

After (With Nova Validation Toast)

Nova Validation Toast Demo

Clean, specific error messages that help users understand and fix validation errors

✨ Features

  • 🎯 Replaces Generic Messages: Shows actual validation errors instead of "There was a problem submitting the form"
  • 🚫 Error Deduplication: Prevents duplicate toast messages within a 2-second window
  • 📱 Console to Toast: Moves validation errors from browser console to user-visible toasts
  • 📋 JsonResponse Support: Displays error messages from JSON responses
  • 1️⃣ Single Toast Display: Shows only one toast per error, preventing message spam
  • 🔧 Server Error Handling: Automatically extracts and displays server validation errors
  • 🌐 Axios Interceptors: Hooks into Nova's requests to catch and display errors
  • ⚙️ Configurable: Easy to extend with additional error patterns
  • ✅ Laravel 10, 11 & 12 Compatible: Works with Laravel 10.x, 11.x, and 12.x
  • ✅ Nova 4 & 5 Compatible: Works with both Nova 4.x and 5.x

📦 Installation

You can install the package via composer:

composer require dmkulyk/nova-validation-toast

The package will automatically register its service provider.

🚀 Usage

The component automatically activates when Nova boots and enhances the default error handling behavior. No additional configuration is required.

Customization

If you need to customize the error patterns or behavior, you can publish the JavaScript assets:

php artisan vendor:publish --tag=nova-validation-toast-assets

Then modify the published JavaScript file in public/vendor/nova-validation-toast/ to suit your needs.

⚙️ Configuration

You can modify the KNOWN_ERRORS object in the JavaScript to add more error patterns that should be suppressed or handled differently:

const KNOWN_ERRORS = {
    formSubmit: 'there was a problem submitting the form',
    // Add more known error strings here as needed
};

🔧 How it Works

The component:

  1. Intercepts Nova's error handling system
  2. Deduplicates error messages to prevent spam
  3. Extracts validation errors from server responses
  4. Displays clean, user-friendly toast notifications
  5. Hooks into both Nova's request system and global axios interceptors

📄 License

The MIT License (MIT). Please see License File for more information.