brokeyourbike/money-validation-laravel

Validation rules for Money and Currency

Downloads

539

Stars

1

Version

1.0.1

money-validation-laravel

Latest Stable Version Total Downloads License: MPL-2.0 tests Maintainability Test Coverage

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

License

Mozilla Public License v2.0

brokeyourbike

Author

brokeyourbike