money-validation-laravel
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(),
],
];
}
}