我正在尝试验证和提交一个用Laravel 5.2制作的网站的表单,当我试图提交表单而没有填写所有必填字段时,问题就来了。StoreRequest检查哪些字段是必填的,并向我返回如下错误:
{"name":["The name field is required."],"email":["The email field is required."],"subject":["The subject field is required."],"content":["The cont
只有当其他两个字段设置为特定值时,表单中的字段才是必需的。这不是required_with_all的情况。这不是如果它们被设置,而是如果它们是专门设置的。
'foo‘=> 'required_if_all:bar,2,bat,1',
我添加了一个服务提供者:
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Validator;
class RequiredIfAllProvider extends ServiceProvider {
/**
* Bo
我有个小问题。我使用Laravel创建简单的API。当我使用验证时,如果它失败了,我会得到一条常见的消息:
{
"result": false,
"message": "The given data failed to pass validation.",
"details": []
}
但是,我如何才能获得有关哪个字段失败以及失败原因的详细信息:
{
"result":false,
"message":"The given data failed to pass valid
我得到了带有一些validationl的对象,请求验证的方法甚至返回了不在验证规则中的字段。下面是我的验证类的样子。
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'terminal' => ['required'],
'terminal.followings' => ['boolean']