Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class SomeRequest extends FormRequest
* Validate conditional rules.
* @return \Illuminate\Contracts\Validation\Validator
protected function getValidatorInstance()
$validator = parent::getValidatorInstance();
$validator->sometimes('g-recaptcha-response', 'required|captcha', function ($input) {
return ! app()->environment('testing');
return $validator;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment