brayancaro / laravel-api-rule
Easy API calls within Laravel rules.
v2.0.0
2024-03-31 23:53 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- nunomaduro/collision: ^6.0 || ^7.0 || ^8.0
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.22 || ^2.0
- pestphp/pest-plugin-laravel: ^1.4 || ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
README
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.