Skip to content

Commit

Permalink
test: add optional test
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 12, 2023
1 parent 2bc65ee commit 86ecc5c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/validation.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit 86ecc5c

Please sign in to comment.