Package Data | |
---|---|
Maintainer Username: | ArondeParon |
Maintainer Contact: | hi@aron.codes (Aron Rotteveel) |
Package Create Date: | 2018-08-17 |
Package Last Update: | 2024-06-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:21:56 |
Package Statistics | |
---|---|
Total Downloads: | 117,092 |
Monthly Downloads: | 1,965 |
Daily Downloads: | 23 |
Total Stars: | 112 |
Total Watchers: | 2 |
Total Forks: | 7 |
Total Open Issues: | 0 |
The arondeparon/laravel-request-sanitizer
package provides a fluent interface to sanitize form requests before validating them.
Often, validating your request is not enough. The request sanitizer allows you to easily
manipulate your form data before passing it to the validator. You can start using it in a matter
of minutes and it is fully compatible with Laravel's FormRequest
object.
Syntax is similar to the way rules
are added to a Form Request.
class StoreCustomerInformationRequest extends FormRequest
{
use SanitizesInputs;
protected $sanitizers = [
'lastname' => [
Capitalize::class,
],
'mobile_phone' => [
RemoveNonNumeric::class
],
];
}
composer require arondeparon/laravel-request-sanitizer
SanitizesInputs
trait to your form request.$sanitizers
property of your form request.Trim
- simple PHP trim()
implementationTrimDuplicateSpaces
replaces duplicate spaces with a single space.RemoveNonNumeric
- removes any non numeric characterCapitalize
- capitalizes the first character of a stringUppercase
- converts a string to uppercaseLowercase
- converts a string to lowercasseWriting your own sanitizer can be done by implementing the Sanitizer
interface, which requires only
one method.
interface Sanitizer
{
public function sanitize($input);
}
$ composer test
The MIT License (MIT). Please see License File for more information.