anonaddy/app/Rules/NotBlacklisted.php
2023-04-26 16:53:39 +01:00

26 lines
558 B
PHP

<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class NotBlacklisted implements ValidationRule
{
/**
* Indicates whether the rule should be implicit.
*
* @var bool
*/
public $implicit = true;
/**
* Run the validation rule.
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (in_array(strtolower($value), config('anonaddy.blacklist'))) {
$fail('The :attribute has already been taken.');
}
}
}