gabrieltakacs / laravel-validation-rules
Set of useful validation rules for Laravel project.
1.0.6
2022-08-08 09:39 UTC
Requires
- php: ^7.1 || ^8.0
- ddeboer/vatin: ^2.2
- illuminate/contracts: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- illuminate/support: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- laravel/framework: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is not auto-updated.
Last update: 2024-12-09 21:09:54 UTC
README
Set of useful validation rules for Laravel project:
- Slovak Company ID (IČO)
- Slovak TAX ID (DIČ)
- Europe VAT ID (IČ DPH)
- Number (which can contain comma / point as decimal separator)
Installation
Install composer package
composer require gabrieltakacs/laravel-validation-rules
Publish language files
php artisan vendor:publish --provider="GabrielTakacs\LaravelValidationRules\ServiceProvider"
Usage
Slovak Company ID
use GabrielTakacs\Validation\Rule\CompanyId;
$request->validate(['company_id' => '12345678'], ['company_id' => new CompanyId()]); // Pass!
Slovak TAX ID
use GabrielTakacs\Validation\Rule\TaxId;
$request->validate(['tax_id' => '0123456789'], ['tax_id' => new TaxId()]); // Pass!
EU VAT ID
use GabrielTakacs\Validation\Rule\VatId;
$request->validate(['vat_id' => 'SK0123456789'], ['vat_id' => new VatId()]); // Pass!
Number
This validator validates numeric attribute, which can contain comma / dot as decimal separator.
use GabrielTakacs\Validation\Rule\Number;
$request->validate(['numeric_attribute' => '11.12'], ['numeric_attribute' => new Number()]); // Pass!
$request->validate(['numeric_attribute' => '1234,5678'], ['numeric_attribute' => new Number()]); // Pass!
$request->validate(['numeric_attribute' => '10'], ['numeric_attribute' => new Number()]); // Pass!