Download the PHP package ygreis/laravel-validators without Composer
On this page you can find all versions of the php package ygreis/laravel-validators. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ygreis/laravel-validators
More information about ygreis/laravel-validators
Files in ygreis/laravel-validators
Package laravel-validators
Short Description Custom validations for the laravel framework
License MIT
Informations about the package laravel-validators
Laravel Validators
Custom validations for the laravel framework
📝 Summary
- Getting Started
- Installation
- How to use?
- Basic usage
- Function makeValidator
- Function makeValidatorThrow
- With Requests
- Example project
✨ Getting Started
Installation
Requires:
1: First, you may use Composer to install Laravel Validators as a dependency into your Laravel project:
How to use?
Basic usage
The package provides two simple functions that can be used, one where errors are returned makeValidator
and the other, if an error occurs, a custom exception is thrown that also returns errors makeValidatorThrow
.
Validator file example (click here)
> Create a file in a folder, example: `\App\Validators\TestValidator`After creating a validation file, see how to use it in the examples below
Function makeValidator
Example of use:
Function makeValidatorThrow
Example of use:
With Requests
You can use Laravel's Requests to validate the data and you can use Validators too.
Request file example (click here)
> Create a file in a folder, example: `\App\Http\Requests\TestRequest`Usage Request in Controller
> Create a controller in a folder, example: `\App\Http\Controllers`When the data is invalid, by default it will redirect to the previous page showing the errors that occurred, to catch the errors in the view you can do something like this:
Get request errors in the view
Example project
We provide a package so you can test all the examples mentioned here, just access the link below :)