Open Trixpua opened 5 years ago
Is there any progress with regards to this issue? I strongly believe that filters should only be applied to inputs that have been passed in the request instead of retuning null for inputs that haven't been passed through.
I think is not difficult to implement this, just need a check if is set the field in request before apply the sanitize.
i got it working by filtering the filters array before it is returned
public function filters()
{
return collect([
'first_name' => 'trim|escape|capitalize',
'last_name' => 'trim|escape|capitalize',
'email' => 'trim',
])->filter(function ($value, $key) {
return $this->input($key) !== null;
})->toArray();
}
I think is interesting add a filter to check "sometimes" laravel rule and just apply the filter if the field isset, because this way if field is not set raise the error that the field is required.