Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在laravel验证中为zipcode编写正则表达式验证?_Laravel_Laravel 5_Laravel 5.5 - Fatal编程技术网

如何在laravel验证中为zipcode编写正则表达式验证?

如何在laravel验证中为zipcode编写正则表达式验证?,laravel,laravel-5,laravel-5.5,Laravel,Laravel 5,Laravel 5.5,我有一张登记表。我需要验证zipcode。验证规则必须为整数,最大长度不大于7 我尝试过验证,但它必须是5。但有些国家有6或4个zipcode。任何帮助都将不胜感激 'zipcode' => 'required|regex:/^[0-9]{5}(\-[0-9]{4})?$/', 如果您只需要数字,至少3但不超过7,则应使用 'zipcode' => 'required|regex:/^[0-9]{3,7}$/' 您希望验证的几个正确和不正确的邮政编码是什么?最小长度是多少

我有一张登记表。我需要验证zipcode。验证规则必须为整数,最大长度不大于7

我尝试过验证,但它必须是5。但有些国家有6或4个zipcode。任何帮助都将不胜感激

'zipcode'   => 'required|regex:/^[0-9]{5}(\-[0-9]{4})?$/',

如果您只需要数字,至少3但不超过7,则应使用

'zipcode'   => 'required|regex:/^[0-9]{3,7}$/'

您希望验证的几个正确和不正确的邮政编码是什么?最小长度是多少?可能与@JonasStaudenmeir重复,至少3个数字。那么,3到7位之间的整数是什么?