Skip to content

Commit 362f574

Browse files
committed
Change to Bailable contract
1 parent cd0a342 commit 362f574

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
namespace Illuminate\Contracts\Validation;
4+
5+
interface Bailable {}

src/Illuminate/Contracts/Validation/StopUponFailure.php

-13
This file was deleted.

src/Illuminate/Validation/Validator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Contracts\Validation\DataAwareRule;
99
use Illuminate\Contracts\Validation\ImplicitRule;
1010
use Illuminate\Contracts\Validation\Rule as RuleContract;
11-
use Illuminate\Contracts\Validation\StopUponFailure;
11+
use Illuminate\Contracts\Validation\Bailable;
1212
use Illuminate\Contracts\Validation\ValidationRule;
1313
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
1414
use Illuminate\Contracts\Validation\ValidatorAwareRule;
@@ -922,8 +922,8 @@ protected function shouldStopValidating($attribute, $rule)
922922
return $this->messages->has($cleanedAttribute);
923923
}
924924

925-
if ($rule instanceof InvokableValidationRule && $rule->invokable() instanceof StopUponFailure) {
926-
return $rule->invokable()->shouldStop();
925+
if ($rule instanceof InvokableValidationRule && $rule->invokable() instanceof Bailable) {
926+
return true;
927927
}
928928

929929
if (isset($this->failedRules[$cleanedAttribute]) &&

tests/Validation/ValidationStopOnFailureTest.php tests/Validation/ValidationRuleWithBailableTest.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,33 @@
33
namespace Illuminate\Tests\Validation;
44

55
use Closure;
6-
use Illuminate\Contracts\Validation\StopUponFailure;
6+
use Illuminate\Contracts\Validation\Bailable;
77
use Illuminate\Contracts\Validation\ValidationRule;
88
use Illuminate\Translation\ArrayLoader;
99
use Illuminate\Translation\Translator;
1010
use Illuminate\Validation\Validator;
1111
use PHPUnit\Framework\TestCase;
1212

13-
class ValidationStopOnFailureTest extends TestCase
13+
class ValidationRuleWithBailableTest extends TestCase
1414
{
1515
public function testFailingStopsFurtherValidation()
1616
{
1717
$trans = new Translator(new ArrayLoader, 'en');
1818
$v = new Validator(
1919
$trans,
2020
['foo' => 'foobar'],
21-
['foo' => [new StoppingValidationRule(), 'numeric']],
21+
['foo' => [new BailableValidationRule(), 'numeric']],
2222
);
2323
$this->assertFalse($v->passes());
2424
$this->assertEquals(
25-
['foo' => ['Illuminate\Tests\Validation\StoppingValidationRule' => []]],
25+
['foo' => ['Illuminate\Tests\Validation\BailableValidationRule' => []]],
2626
$v->failed()
2727
);
2828
}
2929
}
3030

31-
class StoppingValidationRule implements ValidationRule, StopUponFailure
31+
class BailableValidationRule implements ValidationRule, Bailable
3232
{
33-
public function shouldStop(): bool
34-
{
35-
return true;
36-
}
37-
3833
public function validate(string $attribute, mixed $value, Closure $fail): void
3934
{
4035
$fail('failed');

0 commit comments

Comments
 (0)