maxLength = $maxLength; } /** * Run the validation rule. */ public function validate(string $attribute, mixed $value, Closure $fail): void { $strippedText = strip_tags($value ?? ''); $currentLength = strlen($strippedText); if ($currentLength > $this->maxLength) { $fail("The {$attribute} field must not exceed {$this->maxLength} characters (HTML tags excluded). Currently {$currentLength} characters."); } } }