Skip to content

Commit

Permalink
test: add test with label
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Dec 12, 2022
1 parent 57762dd commit 24fd69c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/system/Validation/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,29 @@ static function ($value, $data, &$error, $field) {
);
}

public function testClosureRuleWithLabel(): void
{
$this->validation->setRules([
'secret' => [
'label' => 'シークレット',
'rules' => ['required', static fn ($value) => $value === 'abc'],
'errors' => [
// Specify the array key for the closure rule.
1 => 'The {field} is invalid',
],
],
]);

$data = ['secret' => 'xyz'];
$return = $this->validation->run($data);

$this->assertFalse($return);
$this->assertSame(
['secret' => 'The シークレット is invalid'],
$this->validation->getErrors()
);
}

/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5368
*
Expand Down

0 comments on commit 24fd69c

Please sign in to comment.