Based on the documentations. Exists can have 4 parameters:
exists:table,id,where,0
The question is, What if I wanted it to be where is not. Like where is not 0.
$validator = Validator::make(
array(
'groups' => $groups
),
array(
'groups' => 'required|exists:groups,jid,parent,!=,0'
)
);
You can use
unique
Example
In the rule above, only rows with an account_id of 1 would be included in the unique check.
http://laravel.com/docs/4.2/validation#rule-unique
maybe you can try
<> 0
,that's the SQL for not equalYou can use something like this:
With Laravel 5.2 or later you can prepend the values to be checked against with a
!
:The same login goes for
unique
, only you need the extra parameters:I know you're looking for 'not 0', but for reference sake, you can use
NOT_NULL
, as in:It's not listed in the docs right now, but here is the discussion about it (see very last post)
A custom validator is here
Example usage:
You can pass default value like this: