File: /var/www/quadcode-site/app/Rules/PhoneRule.php
<?php
namespace App\Rules;
use App\Helpers\PhoneHelper;
use Illuminate\Contracts\Validation\Rule;
class PhoneRule implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
*
* @return bool
*/
public function passes($attribute, $value)
{
$phone = PhoneHelper::trim($value);
return 11 <= strlen($phone) && strlen($phone) <= 20;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return __('phone.is_invalid');
}
}