验证 laravel 验证中的两个字段
validation two fileds in laravel validation
我有 2 个字段要检查验证...
parent
tag
我想要这样的东西:
if(parent == 0)
return 'tag is required';
else
return 'tag can be nullable';
我试过这样的方法,但它是错误的:
'parent' => 'nullable|numeric',
'tags' => 'required_with:parent=0|array|max:8',
使用required_if
规则。
The field under validation must be present and not empty if the anotherfield field is equal to any value.
'parent' => 'nullable|numeric',
'tags' => 'required_if:parent,0|array|max:8',
我有 2 个字段要检查验证...
parent
tag
我想要这样的东西:
if(parent == 0)
return 'tag is required';
else
return 'tag can be nullable';
我试过这样的方法,但它是错误的:
'parent' => 'nullable|numeric',
'tags' => 'required_with:parent=0|array|max:8',
使用required_if
规则。
The field under validation must be present and not empty if the anotherfield field is equal to any value.
'parent' => 'nullable|numeric',
'tags' => 'required_if:parent,0|array|max:8',