Answers for "validate unique or equal"

PHP
0

validate unique or equal

//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']
    ]);
Posted by: Guest on July-29-2021

Browse Popular Code Answers by Language