Ran*_*ana 2 php validation laravel laravel-4
我试图在laravel框架中编写一个简单的验证规则.
$rules = array(
'from_account' => 'required',
'to_account' => 'required|same:from_account',
'amount' => 'required|numeric',
'description' => 'required'
);
Run Code Online (Sandbox Code Playgroud)
现在您可以看到验证规则same:from_account将检查并且必须要求to_account与from_account我要完全相反的完全相同,因此,to_account不能相同from_account.
有没有办法告诉规则内部的否定检查还是我必须手动检查?
为什么不在这里查看文档.
并使用这个:
'to_account' => 'required|different:from_account',
Run Code Online (Sandbox Code Playgroud)
甚至(对于游戏):
'from_account' => 'required|different:to_account',
'to_account' => 'required|different:from_account',
Run Code Online (Sandbox Code Playgroud)