Download the PHP package etelford/laravel-api-validation without Composer
On this page you can find all versions of the php package etelford/laravel-api-validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download etelford/laravel-api-validation
More information about etelford/laravel-api-validation
Files in etelford/laravel-api-validation
Package laravel-api-validation
Short Description Custom Validation for Laravel API requests
License MIT
Informations about the package laravel-api-validation
Laravel API Custom Validation
Lightweight package that allows for creating custom validation rules, mainly to be used as an alternative to Form Requests or inline Validators for API requests.
System Requirements
Laravel 5.4+ and PHP >= 7.0.
Installation
Install through Composer.
Usage
First, import the HandlesApiRequests
trait (usually in your base controller):
For custom validation using Laravel's built-in validators, make a validation class:
Then in your controller method, use the validation you just created:
By default if validation fails, a ApiValidationException
exception will be thrown.
If you wish to bypass this, you can pass a third argument to the validate()
method:
From this you, you can get the Validator
instance and access all of Laravel's built in Validation methods:
If you need more specialized validation that can't be handled directly by Laravel's Validator, you can create a Custom Rule and chain it to your validation call:
All versions of laravel-api-validation with dependencies
illuminate/http Version ~5.4
illuminate/container Version ~5.4
illuminate/support Version ~5.4
illuminate/validation Version ~5.4