summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAsko Nõmm <asko@repl.ee>2023-09-25 17:29:52 +0300
committerAsko Nõmm <asko@repl.ee>2023-09-25 17:29:52 +0300
commit57518b03cbf19b8a714d6fcb573f71cb921005e3 (patch)
tree240509fd84f023f289a83577a735fa82fac879f4 /tests
parent8ebb9ca9fbce0982e27296d5016d17d8b20962d6 (diff)
Implement `$fieldNames`, a way to overwrite field names to be more human friendly in error messages.
Diffstat (limited to 'tests')
-rw-r--r--tests/HirdTest.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/HirdTest.php b/tests/HirdTest.php
index 9e49467..35f4895 100644
--- a/tests/HirdTest.php
+++ b/tests/HirdTest.php
@@ -88,3 +88,21 @@ test('Validate an incorrect correct date format', function () {
'date does not match the required date format Y-m-d H:i:s.',
]);
});
+
+test('Validate using a overwritten field name', function () {
+ $fields = ['date' => '2020-09-17 15:00'];
+ $fieldNames = ['date' => 'Date'];
+ $rules = ['date' => 'date-format:Y-m-d H:i:s'];
+
+ $hird = new Hird(
+ fields: $fields,
+ rules: $rules,
+ fieldNames: $fieldNames
+ );
+
+ $hird->fails();
+
+ expect($hird->errors())->toBe([
+ 'Date does not match the required date format Y-m-d H:i:s.',
+ ]);
+});