d2d.emegrendeles.hu/app/Rules/PhoneRule.php

39 lines
824 B
PHP

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class PhoneRule implements Rule
{
public static string $placeHolder = '+36 30 999 9999';
public static string $inputMaskPatter = '+9[9] 9[9] 999 999[9]';
public static string $regexPattern = "^[\/+][0-9]{1,3}[ ][0-9]{1,3}[ ][0-9]{3}[ ][0-9]{3,9}$";
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function passes($attribute, $value)
{
return (bool) preg_match('/'.PhoneRule::$regexPattern.'/', $value);
}
/**
* Get the validation error message.
*/
public function message()
{
return trans('validation.phone');
// return 'The validation error message.';
}
}