max = $max; } /** * Run the validation rule. */ public function validate(string $attribute, mixed $value, Closure $fail): void { if (! is_string($value)) { $fail("The {$attribute} must be a string."); return; } $count = grapheme_strlen($value); if ($count > $this->max) { $fail("The {$attribute} may not be greater than {$this->max} graphemes."); } } }