PHPackages                             soleinjast/symfony-validation-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. soleinjast/symfony-validation-response

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

soleinjast/symfony-validation-response
======================================

Clean and customizable validation error responses for Symfony APIs

v1.4.2(5mo ago)7609↑192.9%1MITPHPPHP &gt;=8.4CI passing

Since Dec 25Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/soleinjast/symfony-validation-response)[ Packagist](https://packagist.org/packages/soleinjast/symfony-validation-response)[ RSS](/packages/soleinjast-symfony-validation-response/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (12)Versions (11)Used By (0)

Symfony Validation Response Bundle
==================================

[](#symfony-validation-response-bundle)

 [![Symfony Validation Response Bundle](/docs/doc-banner-img.png)](/docs/doc-banner-img.png)

 [![Latest Stable Version](https://camo.githubusercontent.com/142616ac3cb5fe3365293cfb939b69a3be3df574784616bf402039a10813add8/68747470733a2f2f706f7365722e707567782e6f72672f736f6c65696e6a6173742f73796d666f6e792d76616c69646174696f6e2d726573706f6e73652f76)](https://packagist.org/packages/soleinjast/symfony-validation-response) [![Total Downloads](https://camo.githubusercontent.com/d608210f0deac1b29ff8d3cd39621e5d5603569eec5a78d167bec12759fdc3a9/68747470733a2f2f706f7365722e707567782e6f72672f736f6c65696e6a6173742f73796d666f6e792d76616c69646174696f6e2d726573706f6e73652f646f776e6c6f616473)](https://packagist.org/packages/soleinjast/symfony-validation-response) [![License](https://camo.githubusercontent.com/8e7de117ef33bc7e1d6971e9ac72d1a6a34950faa51ab765239cdf01837b3ed1/68747470733a2f2f706f7365722e707567782e6f72672f736f6c65696e6a6173742f73796d666f6e792d76616c69646174696f6e2d726573706f6e73652f6c6963656e7365)](https://packagist.org/packages/soleinjast/symfony-validation-response) [![PHP Version](https://camo.githubusercontent.com/6e44ad49e5307c87d1393389feb52ab61c99956e2e5f8c77177b2501f1d3d47f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d3838393242462e737667)](https://camo.githubusercontent.com/6e44ad49e5307c87d1393389feb52ab61c99956e2e5f8c77177b2501f1d3d47f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d3838393242462e737667) [![Symfony Version](https://camo.githubusercontent.com/26682bccb0cbf3940b0d85a090d03fc05b6e78a81e346285cc9471b89b72883e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e33253230253743253230253545372e30253230253743253230253545382e302d3030303030302e737667)](https://camo.githubusercontent.com/26682bccb0cbf3940b0d85a090d03fc05b6e78a81e346285cc9471b89b72883e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e33253230253743253230253545372e30253230253743253230253545382e302d3030303030302e737667)

A lightweight Symfony bundle that automatically transforms validation errors from `#\[MapRequestPayload\]`, `#\[MapQueryString\]`, and `#\[MapUploadedFile\]` attributes into clean, developer-friendly JSON responses. Stop writing repetitive error handling code in every controller. Let this bundle handle it for you.

---

📑 Table of Contents
-------------------

[](#-table-of-contents)

- [Features](#-features)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Response Formats](#-response-formats)
- [Configuration](#%EF%B8%8F-configuration)
- [Custom Formatter](#-custom-formatter)
- [Usage Examples](#-usage-examples)
- [CLI Testing Tool](#-cli-testing-tool)
- [Testing](#-testing)
- [Requirements](#-requirements)
- [Contributing](#-contributing)
- [License](#-license)

---

✨ Features
----------

[](#-features)

- ✅ **Zero Configuration** - Works immediately after installation with sensible defaults
- ✅ **Multiple Formats** - Simple (default), Nested, or RFC 7807 Problem Details
- ✅ **Clean JSON Responses** - No verbose Symfony debug output
- ✅ **RFC 7807 Compliant** - Industry-standard Problem Details for HTTP APIs
- ✅ **Automatic Error Formatting** - Intercepts validation exceptions and formats them consistently
- ✅ **Type-Safe** - Built with PHP 8.4+ strict types and modern practices
- ✅ **Lightweight** - Minimal footprint with no external dependencies beyond Symfony core
- ✅ **Well Tested** - Comprehensive PHPUnit test coverage
- ✅ **Production Ready** - Battle-tested error handling for REST APIs

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require soleinjast/symfony-validation-response
```

The bundle will auto-register itself if you're using Symfony Flex. Otherwise, add it manually to `config/bundles.php`:

```
return [
    // ...
    Soleinjast\ValidationResponse\ValidationResponseBundle::class => ['all' => true],
];
```

That's it! No additional configuration required.

---

🚀 Quick Start
-------------

[](#-quick-start)

### Step 1: Create a DTO (Data Transfer Object)

[](#step-1-create-a-dto-data-transfer-object)

Define your request structure with validation constraints:

```
