brokeyourbike / money-validation-laravel
Validation rules for Money and Currency
Fund package maintenance!
brokeyourbike
Open Collective
Requires
- php: ^8.0
- illuminate/contracts: ^8|^9
- moneyphp/money: ^4
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- orchestra/testbench: ^6.21
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-20 14:36:13 UTC
README
Validation rules for Money and Currency
Installation
composer require brokeyourbike/money-validation-laravel
Usage
Package uses service container for currencies resolution. You can set it in your AppServiceProvider
use Money\Currencies\ISOCurrencies; use Money\Currencies; public function register() { $this->app->singleton(Currencies::class, function () { return new ISOCurrencies(); }); }
use Illuminate\Foundation\Http\FormRequest; use BrokeYourBike\MoneyValidation\IsValidCurrency; class ExampleRequest extends FormRequest { public function rules() { return [ 'currency_code' => [ 'required', 'string', 'size:3', new IsValidCurrency(), ], ]; } }
Authors
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk