mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 18:31:36 +00:00
21 lines
500 B
PHP
Executable File
21 lines
500 B
PHP
Executable File
<?php
|
|
|
|
namespace App\ValidationRules;
|
|
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class DomainRule implements ValidationRule
|
|
{
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (! $value) {
|
|
return;
|
|
}
|
|
if (preg_match("/^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}$/", $value) === 1) {
|
|
return;
|
|
}
|
|
$fail('Domain is not valid')->translate();
|
|
}
|
|
}
|