Monday, May 22, 2017

How to validate params in REST Lumen/Laravel request?

Route: $app->get('/ip/{ip}', GeoIpController::class . '@show');

How to validate ip's properly? I've tried to inject Request object in show method, but wasn't able to solve this. I want to stick with REST, so using URL parameters is not solution for me. I use it for API purposes, so status code as response would be appropriate.

Also tried that way:

$app->bind('ip', function ($ip) {
    $this->validate($ip, [
        'ip' => 'required|ip',
    ]);
});



via wujt

Advertisement