22 lines
558 B
PHP
22 lines
558 B
PHP
<?php
|
||
|
||
namespace App\Rules;
|
||
|
||
use Closure;
|
||
use Illuminate\Contracts\Validation\ValidationRule;
|
||
|
||
class OnlyLetters implements ValidationRule
|
||
{
|
||
/**
|
||
* Run the validation rule.
|
||
*
|
||
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||
*/
|
||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||
{
|
||
if (! preg_match('/^([a-zA-Zа-яZžŽäÄňŇöÖşŞüÜçÇýÝ])+$/', $value)) {
|
||
$fail('The :attribute field must only contain letters.');
|
||
}
|
||
}
|
||
}
|