padavvan / yii2-luhn-validator
Luhn validate
1.0.2
2017-07-12 20:19 UTC
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.0
Requires (Dev)
- codeception/base: ^2.2.3
- codeception/specify: ~0.4.3
- codeception/verify: ~0.3.1
This package is not auto-updated.
Last update: 2024-05-12 01:49:26 UTC
README
Checking the number by Luhn algorithm. Look more about Luhn algorithm at wikipedia.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require padavvan/yii2-luhn-validator
or add
"padavvan/yii2-luhn-validator": "~1.0.2"
to the require section of your composer.json file.
Usage
Look more about Yii2 validators
public function rules() { return [ ['creditCard', LuhnValidator::className()] ]; } // OR $model = \yii\base\DynamicModel::validateData(['digits' => '...'], [ ['digits', LuhnValidator::className()] ]); // OR LuhnValidator::check($digits); // return true or false
Tests
cd vendor/padavvan/yii2-luhn-validator
php ../../bin/codecept run