Validates an ip address is either public or private. Supports ipv4 & ipv6.
composer require laravel-validation-rules/ip
Validate an ip address is a public address.
use LVR\IP\PublicAddress;
$request->validate([
'ip' => ['required', new PublicAddress],
]);
Validate an ip address is a private address.
use LVR\IP\PrivateAddress;
$request->validate([
'ip' => ['required', new PrivateAddress],
]);