Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sebastiansulinski/laravel-validation

Validation wrapper for Laravel 6+ and 5.8
https://github.com/sebastiansulinski/laravel-validation

laravel validation validation-messages

Last synced: 12 days ago
JSON representation

Validation wrapper for Laravel 6+ and 5.8

Awesome Lists containing this project

README

        

# Laravel validation wrapper

This package, when used with form requests expecting Json, generates Json response with the errors representing rule index rather than message for a failed rule i.e.

```php
[
'message' => 'The given data was invalid.',
'errors' => [
'name' => ['required', 'max'],
'email' ['email'],
],
]
```

If request is not expecting Json - default Laravel redirect response with errors stored in session is being used.

Using this package with front and back end validation allows us having validation message directly with the form and only reveal the relevant one based on which rule failed the validation.

## Installation

```bash
composer require sebastiansulinski/laravel-validation
```

## Service Provider

Replace default `Illuminate\Validation\ValidationServiceProvider::class` provider in `config/app.php`:

```php
[
...
// Illuminate\Validation\ValidationServiceProvider::class, - remove
SSD\LaravelValidation\ValidationServiceProvider::class,

],
];
```