Refactor imports and formatting in various Filament resources; add SMS sending helper function
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\PhoneNumberVerification\Rules;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
|
||||
class PhoneNumberVerificationRule implements ValidationRule
|
||||
{
|
||||
/**
|
||||
* Run the validation rule.
|
||||
*
|
||||
* @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail
|
||||
*/
|
||||
public function validate(string $attribute, mixed $value, Closure $fail): void
|
||||
{
|
||||
if (! is_numeric($value)) {
|
||||
$fail('Telefon belgisi diňe sanlardan ybarat bolmaly.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$number = (int) $value;
|
||||
|
||||
$isValid = ($number >= 61000000 && $number <= 65999999) || ($number >= 71000000 && $number <= 71999999);
|
||||
|
||||
if (! $isValid) {
|
||||
$fail('Telefon belgisi nädogry aralykda.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user