Skip to content

BrayanCaro/laravel-api-rule

Repository files navigation

Easy API calls within Laravel rules.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Easy API calls within Laravel rules.

Installation

You can install the package via composer:

composer require brayancaro/laravel-api-rule

Usage

# 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()],
        # ...
    ]);
 
    # ...
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.