test(validator): rename enum rule to in

This commit is contained in:
kj
2026-09-14 16:44:31 -03:00
parent f4b112032e
commit 2e96aa886e

View File

@@ -81,10 +81,18 @@ final class ValidatorTest extends TestCase
#[Test]
public function enumIsLooseComparison(): void
public function inIsLooseComparison(): void
{
$this->assertTrue(Validator::checkRule('1', 'enum:1,2,3'));
$this->assertFalse(Validator::checkRule('9', 'enum:1,2,3'));
$this->assertTrue(Validator::checkRule('1', 'in: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]
@@ -100,7 +108,7 @@ final class ValidatorTest extends TestCase
public function parseRule(): void
{
$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$/'));
}
@@ -168,7 +176,7 @@ final class ValidatorTest extends TestCase
);
$this->assertSame(
'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(
'The reason field is required when mode is other.',