Download the PHP package andrey-vasin/laravel-request-filters without Composer
On this page you can find all versions of the php package andrey-vasin/laravel-request-filters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrey-vasin/laravel-request-filters
More information about andrey-vasin/laravel-request-filters
Files in andrey-vasin/laravel-request-filters
Package laravel-request-filters
Short Description Simple & lean request filtering for Laravel 5.6+
License MIT
Homepage https://github.com/andrey-vasin/laravel-request-filters
Informations about the package laravel-request-filters
Laravel request filters
About
Laravel provides tools to validate HTTP requests allowing developers to ensure the input data is in the correct structure.
This package provides tools to filter the valid data into the format intended.
It feels like it is part of the Laravel framework and couldn't be any simpler to use.
Requirements
Laravel 5.6+
Features
- Format input with a collection of pre-made and tested Filters
- trait that easily plugs into a and enable filtering
- that allows developers to easily implement their own filters
- tool that can apply the same filters to any string you pass in
- Nested AND array filtering just like Laravel's own validator :ok_hand:
- String based filtering similar to Laravel's validator + custom parsable filters
Included Filters
Filter class | Usage |
---|---|
FilterCapitalize | Capitalizes the first character of each word |
FilterSanitize | Escapes characters based on php's own validator constants |
FilterSanitizeEmail | Sanitizes email |
FilterSanitizeText | Sanitizes text generically |
FilterSanitizeEncoded | URL Encodes text |
FilterNumeric | Removes all non-numerical characters |
FilterStripTag | Removes HTML and PHP tags, keeps what you want |
FilterToLower | Converts to lowercase |
FilterToUpper | Converts to uppercase |
FilterTrim | Trim leading and trailing white space |
FilterDate | Format into a specified Carbon date string see Carbon docs |
Included Filters (as string literals)
Filter class | Usage |
---|---|
'capitalize' | Capitalizes the first character of each word |
'email' | Sanitizes email |
'sanitize' | Sanitizes text generically |
'encode' | URL Encodes text |
'number' | Removes all non-numerical characters |
'strip' | Removes HTML and PHP tags, keeps what you want |
'lowercase' | Converts to lowercase |
'uppercase' | Converts to uppercase |
'trim' | Trim leading and trailing white space |
'date' | Format into a specified Carbon date string see Carbon docs |
You can make your own custom filters by implementing the :)
How to use
Import via composer:
In your FormRequest use the following trait:
Describe your filters (Laravel rules included for familiarisation):
Or use the string based syntax:
Validate the request as per normal but, the results will be now filtered :)
You can optionally just run the filter on any string you like outside of the request:
Using your own custom filtering rules to the string parsing syntax is easy!