Skip to content

Commit

Permalink
Revert "Make rules method in FormRequest optional (laravel#46846)"
Browse files Browse the repository at this point in the history
This reverts commit 0c9b3e9.
  • Loading branch information
snarcraft authored Apr 26, 2023
1 parent 09ca3f2 commit 51746ac
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Http/FormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function getValidatorInstance()
*/
protected function createDefaultValidator(ValidationFactory $factory)
{
$rules = method_exists($this, 'rules') ? $this->container->call([$this, 'rules']) : [];
$rules = $this->container->call([$this, 'rules']);

$validator = $factory->make(
$this->validationData(), $rules,
Expand Down
17 changes: 0 additions & 17 deletions tests/Foundation/FoundationFormRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ public function testValidatedMethodReturnsOnlyRequestedNestedValidatedData()
$this->assertSame('bar', $request->validated('nested.foo'));
}

public function testRequestCanPassWithoutRulesMethod()
{
$request = $this->createRequest([], FoundationTestFormRequestWithoutRulesMethod::class);

$request->validateResolved();

$this->assertEquals([], $request->all());
}

/**
* Catch the given exception thrown from the executor, and return it.
*
Expand Down Expand Up @@ -386,11 +377,3 @@ public function authorize()
return Response::allow('baz');
}
}

class FoundationTestFormRequestWithoutRulesMethod extends FormRequest
{
public function authorize()
{
return true;
}
}

0 comments on commit 51746ac

Please sign in to comment.