test(validator): rename enum rule to in
This commit is contained in:
@@ -81,10 +81,18 @@ final class ValidatorTest extends TestCase
|
|||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
|
||||||
public function enumIsLooseComparison(): void
|
public function inIsLooseComparison(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue(Validator::checkRule('1', 'enum:1,2,3'));
|
$this->assertTrue(Validator::checkRule('1', 'in:1,2,3'));
|
||||||
$this->assertFalse(Validator::checkRule('9', 'enum:1,2,3'));
|
$this->assertFalse(Validator::checkRule('9', 'in:1,2,3'));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
|
||||||
|
public function enumRuleIsNoLongerRecognized(): void
|
||||||
|
{
|
||||||
|
$this->expectException(\Exception::class);
|
||||||
|
Validator::checkRule('1', 'enum:1,2,3');
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
@@ -100,7 +108,7 @@ final class ValidatorTest extends TestCase
|
|||||||
public function parseRule(): void
|
public function parseRule(): void
|
||||||
{
|
{
|
||||||
$this->assertSame(['required', ''], Validator::parseRule('required'));
|
$this->assertSame(['required', ''], Validator::parseRule('required'));
|
||||||
$this->assertSame(['enum', 'a,b'], Validator::parseRule('enum:a,b'));
|
$this->assertSame(['in', 'a,b'], Validator::parseRule('in:a,b'));
|
||||||
$this->assertSame(['regex', '/^a,b$/'], Validator::parseRule('regex:/^a,b$/'));
|
$this->assertSame(['regex', '/^a,b$/'], Validator::parseRule('regex:/^a,b$/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +176,7 @@ final class ValidatorTest extends TestCase
|
|||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
'The selected status is invalid. Allowed: a, b, c.',
|
'The selected status is invalid. Allowed: a, b, c.',
|
||||||
Validator::message('status.enum:a,b,c')
|
Validator::message('status.in:a,b,c')
|
||||||
);
|
);
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
'The reason field is required when mode is other.',
|
'The reason field is required when mode is other.',
|
||||||
|
|||||||
Reference in New Issue
Block a user