Lae/app/Rules/Domain.php

28 lines
546 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Domain implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
*/
public function passes($attribute, $value): bool
{
2023-02-17 13:18:26 +00:00
return filter_var($value, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) !== false;
}
/**
* Get the validation error message.
*/
public function message(): string
{
return '域名格式不正确。';
}
}