本文介绍了Laravel验证-数字必须以0(零)开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何进行输入验证以确保数字必须以0开头?

How to do input validation that a number must start with 0?

例如:

$rules = [
    'full_name' => 'required|min:6',
    'number' => 'required|numeric|min:5',
];

number字段上,它必须为数字,且必须至少为5位数字.我还需要包括必须以0开头的规则?

On the number field, it is requred, must be numberic only and minimum of 5 digits. I also need to include rule that it must start with 0?

推荐答案

在数组内部使用laravel regex:pattern验证器()和类似以下内容的正则表达式:/^[0][0-9]{4,}/

Use laravel regex:pattern validator, inside an array (Issue with Laravel Rules & Regex (OR) operator) and a regex of something like this: /^[0][0-9]{4,}/

这篇关于Laravel验证-数字必须以0(零)开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 18:48