📜  验证唯一或相等 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:30.480000             🧑  作者: Mango

代码示例1
//Use an if statement to validate some items conditionally:
$request->validate([ //Always validated
    'name' => ['string'],
    'some_number' => ['numeric', 'integer']
]);
if ($request->email != $user->email) //Validated only if different from user's currently stored email
    $request->validate([
        'email' => ['email', 'unique:users']
    ]);