From 86ecc5c1799b1a26b16cfcff3dbb451f8611ad1e Mon Sep 17 00:00:00 2001 From: mychidarko Date: Sun, 12 Nov 2023 21:51:53 +0000 Subject: [PATCH] test: add optional test --- tests/validation.test.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/validation.test.php b/tests/validation.test.php index 65b01f7..4900ff3 100644 --- a/tests/validation.test.php +++ b/tests/validation.test.php @@ -60,3 +60,12 @@ expect($validatedData)->toBe(false); expect(Form::errors())->toHaveKey('test5'); }); + +test('optional rule works correctly no matter it\'s position', function () { + $itemsToValidate = []; + + $validatedData = Form::validate($itemsToValidate, ['test6' => 'text|email|optional']); + + expect($validatedData)->toBe($itemsToValidate); + expect(Form::errors())->not()->toHaveKey('test6'); +});