32 lines
606 B
PHP
32 lines
606 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Helpers\PhoneNumber as PhoneNumberHelper;
|
|
use Illuminate\Contracts\Validation\Rule;
|
|
|
|
class PhoneNumber implements Rule
|
|
{
|
|
/**
|
|
* Determine if the validation rule passes.
|
|
*
|
|
* @param string $attribute
|
|
* @param mixed $value
|
|
* @return bool
|
|
*/
|
|
public function passes($attribute, $value): bool
|
|
{
|
|
return PhoneNumberHelper::validate($value);
|
|
}
|
|
|
|
/**
|
|
* Get the validation error message.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function message()
|
|
{
|
|
return '手机号码格式不正确';
|
|
}
|
|
}
|