Conditional validation in laravel

Updated at 03-Sep-2021, By samar

Conditional validation in laravel

In this session, we are going to try to solve the "Conditional validation in laravel" puzzle by using the computer language.

Sometimes we have to pass the conditional validation in laravel form validation in that case it provides a rule (sometimes) for conditional validation on input field which validate input data if it is present in input request.
  • Validate field if present in input request in laravel using sometimes rule

    use Illuminate\Support\Facades\Validator;
    $v = Validator::make($data, [
        'email' => 'sometimes|required|email',
    ]);
    

    It will validate the input field if it’s present input request.

Back to code snippet queries related laravel