Laravel - Validation - Validating When Present

In some situations, you may wish to run validation checks against a field only if that field is present in the data being validated. To quickly accomplish this, add the sometimes rule to your rule list:

    $v = Validator::make($data, [
        'email' => 'sometimes|required|email',

In the example above, the email field will only be validated if it is present in the $data array.

If you are attempting to validate a field that should always be present but may be empty, check out this note on optional fields.