From ddda992da505f8f61f456558d127cbd564153ba3 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Tue, 19 Nov 2024 14:29:34 +0700 Subject: [PATCH] feat(validation): `ArrayList` rule (#745) --- .../Validation/src/Rules/ArrayList.php | 22 ++++++++++++++++ .../Validation/tests/Rules/ArrayListTest.php | 25 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/Tempest/Validation/src/Rules/ArrayList.php create mode 100644 src/Tempest/Validation/tests/Rules/ArrayListTest.php diff --git a/src/Tempest/Validation/src/Rules/ArrayList.php b/src/Tempest/Validation/src/Rules/ArrayList.php new file mode 100644 index 000000000..cb5e0975b --- /dev/null +++ b/src/Tempest/Validation/src/Rules/ArrayList.php @@ -0,0 +1,22 @@ +assertFalse($rule->isValid(['foo' => 'bar'])); + $this->assertTrue($rule->isValid([])); + $this->assertTrue($rule->isValid(['a', 'b', 'c'])); + $this->assertFalse($rule->isValid([0 => 'a', 1 => 'b', 3 => 'c'])); + $this->assertSame('Value must be a list', $rule->message()); + } +}