i´m using lumen 5.5 and want to prove that a given value is required
, exists in table A
and does NOT exist in table B
.
while the first two rules can be found in the documentation I´m unable to find a solution for the third.
So this is what I currently use:
$rules = [
'email' => 'required|exists:user,email'
];
Something like this is what I want:
$rules = [
'email' => 'required|exists:user,email|not_exists:blocklist,email'
];
Someone know a simple validation rule for this?
Try this:
$rules = [
'email' => 'required|exists:users|unique:blocklist'
];
Explanation:
users
table under the column email
. blocklist
table (under the email
column).In both cases, I didn't specify a column name because the attribute name is the same than the matching column in the database. If you want to customize it just include it after a ,
. e.g: required|exists:users,another_column