Files
online.tbbank.gov.tm-larave…/app/Rules/OnlyLetters.php
2023-11-28 17:31:52 +05:00

22 lines
558 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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.');
}
}
}