summaryrefslogtreecommitdiff
path: root/src/Validators/LenValidator.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Validators/LenValidator.php')
-rw-r--r--src/Validators/LenValidator.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Validators/LenValidator.php b/src/Validators/LenValidator.php
index ca4e486..3fa6fbf 100644
--- a/src/Validators/LenValidator.php
+++ b/src/Validators/LenValidator.php
@@ -12,6 +12,12 @@ namespace Asko\Hird\Validators;
*/
class LenValidator implements Validator
{
+ public function __construct(
+ private array $fields,
+ private array $fieldNames,
+ ) {
+ }
+
/**
* Returns a boolean `true` when given `$value` is as long as
* required. Returns `false` otherwise.
@@ -43,6 +49,6 @@ class LenValidator implements Validator
*/
public function composeError(string $field, mixed $modifier = null): string
{
- return "{$field} is shorter than the required {$modifier} characters.";
+ return "{$this->fieldNames[$field]} is shorter than the required {$modifier} characters.";
}
}