Manipulating request data before performing validation in Laravel
5 years ago
When using form request classes, it can be really handy to be able to manipulate the request data before running any of the validation rules. This could be to:
- Coerce the data into a format the validation is expecting (e.g. convert a list of comma separated values to an array).
- Cast a value to another type (e.g. string to integer or string to boolean)
- Account for common user errors, like typos.
- Remove inappropriate or potentially malicious content from input data.
This article is submitted by BenSampo
Link: