Skip to content

Commit 0c174d8

Browse files
authored
Ability to set custom validation message
1 parent b943e26 commit 0c174d8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PasswordExposed.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class PasswordExposed implements Rule
1010
{
1111
private $passwordExposedChecker;
12+
private $message = 'The :attribute has been exposed in a data breach.';
1213

1314
public function __construct(PasswordExposedChecker $passwordExposedChecker = null)
1415
{
@@ -41,6 +42,19 @@ public function passes($attribute, $value)
4142
*/
4243
public function message()
4344
{
44-
return 'The :attribute has been exposed in a data breach.';
45+
return $this->message;
46+
}
47+
48+
/**
49+
* Set a custom validation error message.
50+
*
51+
* @param string $customMessage
52+
*
53+
* @return \DivineOmega\LaravelPasswordExposedValidationRule\PasswordExposed
54+
*/
55+
public function setMessage($message)
56+
{
57+
$this->message = $message;
58+
return $this;
4559
}
4660
}

0 commit comments

Comments
 (0)