part of my controller
$validator = Validator::make($request->all(), [
'displayed_total_rate' => 'required',
'is_dropoff_city_defferent' => 'nullable|in:1,0',
//some other fields ...
]);
$validator->after(function ($validator) use ($request) {
if (!$validator->fails()) {
if ($some_checkings_if_prevous_validation_not_failed) {
$validator->errors()->add('field', 'some error');
}
}
});
at the execution of code
if (!$validator->fails()) {
it run infinitly, so how to check the prevous validation failed or not inside $validator->after function?