Skip to content

Commit 02038b9

Browse files
committed
test: add test with label
1 parent 64f894c commit 02038b9

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/system/Validation/ValidationTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,29 @@ static function ($value, $data, &$error, $field) {
256256
);
257257
}
258258

259+
public function testClosureRuleWithLabel(): void
260+
{
261+
$this->validation->setRules([
262+
'secret' => [
263+
'label' => 'シークレット',
264+
'rules' => ['required', static fn ($value) => $value === 'abc'],
265+
'errors' => [
266+
// Specify the array key for the closure rule.
267+
1 => 'The {field} is invalid',
268+
],
269+
],
270+
]);
271+
272+
$data = ['secret' => 'xyz'];
273+
$return = $this->validation->run($data);
274+
275+
$this->assertFalse($return);
276+
$this->assertSame(
277+
['secret' => 'The シークレット is invalid'],
278+
$this->validation->getErrors()
279+
);
280+
}
281+
259282
/**
260283
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5368
261284
*

0 commit comments

Comments
 (0)