danielebarbaro / laravel-credit-card-validator
laravel-credit-card-validator is a package to validate a credit card number.
Requires
- php: ^7.1|8.*
- illuminate/contracts: 5.*|6.*|7.*|8.*
- illuminate/support: 5.*|6.*|7.*|8.*
Requires (Dev)
- orchestra/testbench: 3.8.*|^4.0
- phpunit/phpunit: ^7.5|^8.0
- squizlabs/php_codesniffer: ^3.4
This package is not auto-updated.
Last update: 2024-12-13 00:27:18 UTC
README
laravel-credit-card-validator is a package to validate credit card number usign Luhn Algo .
Installation
You can install the package via composer:
composer require danielebarbaro/laravel-credit-card-validator
The package will automatically register itself.
Usage
use Danielebarbaro\LaravelCreditCardValidator\Facades\CreditCardValidatorFacade as CreditCardValidator; // Check Credit Card CreditCardValidator::validate('4579880200630196');
Validation
The package registers a new validation rule.
credit_card_number
use Illuminate\Http\Request; class Controller { public function foo(Request $request) { $request->validate([ 'field' => ['credit_card_number'], ]); } }
Alternatively, you can also use the Rule
directly.
use Illuminate\Http\Request; use Danielebarbaro\LaravelCreditCardValidator\Rules; class Controller { public function foo(Request $request) { $request->validate([ 'field' => [ new Rules\CreditCardNumber() ], ]); } }
Translations
Just add and customize validation strings in resources/lang/en/validation.php
...
'credit_card_number' => 'The :attribute must be a valid Credit Card number',
...
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email barbaro.daniele@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.