有没有办法在Laravel中全局验证电话号码?

时间:2019-07-02 11:09:34

标签: php laravel laravel-5

我已经在Laravel中验证了基于阿联酋的电话号码。有什么方法可以验证所有国家/地区的号码(不仅限于阿联酋)?

$messages = [
    'required' => 'The :attribute field is required.',
    'integer' => 'The :attribute field value should be an integer.',
    'regex' => 'The :attribute is invalid',
    'digits' => 'The :attribute is invalid',
];

$validator = Validator::make($request->all(),
    [
        'number' => 'required|digits:12|regex:/(9715)[0-9]{8}/',
        'service' => 'required|integer'
    ],
    $messages
);

0 个答案:

没有答案