Easy API calls within Laravel rules.
You can install the package via composer:
composer require brayancaro/laravel-api-rule
# Create a rule
use BrayanCaro\ApiRule\ApiRule;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
class DummyRule extends ApiRule
{
protected function pullResponse($value): Response
{
return Http::get("dummy.com/$value");
}
}
And use it as a normal rule:
public function store(Request $request)
{
$validated = $request->validate([
'some_attribute' => ['required', DummyRule::make()],
# ...
]);
# ...
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.