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
Description:
The problem is getting the retrieve the validated input data with method validated(). When it is called, it re-initiates the request validation.
Steps To Reproduce:
Controller:
use App\Http\Requests\UserRequest;
class UserController extends Controller
{
public function sandbox(UserRequest $request)
{
return response()->json($request->validated());
}
}
RequestAbstract:
use Pearl\RequestValidate\RequestAbstract;
use Illuminate\Validation\Rule;
class UserRequest extends RequestAbstract
{
public function rules()
{
return [
'full_name' => 'required|string|max:50',
'phone' => [
'required',
'max:50',
'regex:/^(\+[0-9]+)$/',
Rule::unique('clients')->where(function($query){
return $query->where('account_id', auth()->user()->account_id);
})
],
'email' => 'nullable|email|max:50',
'info' => 'max:200'
];
}
}
Debugbar:
Since the rules have a check in the database, we can see a duplicated query to the database, which means that the method rules() was called twice.
The text was updated successfully, but these errors were encountered:
Slisarenko
changed the title
[FormRequest] validated() method causes the validation to be called again.
[RequestAbstract] validated() method causes the validation to be called again.
Aug 31, 2022
Lumen Version: 8.x
PHP Version: 7.4
Description:
The problem is getting the retrieve the validated input data with method validated(). When it is called, it re-initiates the request validation.
Steps To Reproduce:
Since the rules have a check in the database, we can see a duplicated query to the database, which means that the method rules() was called twice.
The text was updated successfully, but these errors were encountered: