You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checked that your question isn't already asked before.
Filled in the entire issue template
Versions
PHP version: 7.3.6
Laravel version: 5.8.33
Package version: 3.1.15
Description
Is there any way to manipulate data before validation? I have to trim strings and convert empty strings to null before validation.
Laravel has \Illuminate\Foundation\Http\Middleware\TrimStrings and \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull middlewares.
I think we should add something like prepareForValidation function on withValidation trait or define a new trait with a function to be invoked after reading the row and before validation.
/**
* Prepare row value for validation.
*
* @param array $rows
* @return array
*/
public function manipulateRow(array $row): array
{
return array_map('trim', $row);
}
The text was updated successfully, but these errors were encountered:
Prerequisites
Versions
Description
Is there any way to manipulate data before validation? I have to trim strings and convert empty strings to null before validation.
Laravel has
\Illuminate\Foundation\Http\Middleware\TrimStrings
and\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull
middlewares.I think we should add something like
prepareForValidation
function onwithValidation
trait or define a new trait with a function to be invoked after reading the row and before validation.The text was updated successfully, but these errors were encountered: