PHPackages                             giahojnost/credit-card-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. giahojnost/credit-card-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

giahojnost/credit-card-validator
================================

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

1.0.0(3y ago)07MITPHPPHP &gt;=7.4

Since Apr 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/giahojnost/CreditCardValidator)[ Packagist](https://packagist.org/packages/giahojnost/credit-card-validator)[ RSS](/packages/giahojnost-credit-card-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Credit Card Validator
=====================

[](#credit-card-validator)

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.

Based on [inacho/php-credit-card-validator](https://github.com/inacho/php-credit-card-validator), for support PHP 8.

Installation
------------

[](#installation)

Require the package in `composer.json`

```
"require": {
    "giahojnost/credit-card-validator": "1.*"
},
```

If you are using Laravel, add an alias in `config/app.php`

```
'aliases' => array(

    'App'             => 'Illuminate\Support\Facades\App',
    ...
    'View'            => 'Illuminate\Support\Facades\View',

    'CreditCard'      => 'Giahojnost\CreditCard',

),
```

Usage
-----

[](#usage)

### Validate a card number knowing the type:

[](#validate-a-card-number-knowing-the-type)

```
$card = CreditCard::validCreditCard('5500005555555559', 'mastercard');
print_r($card);
```

Output:

```
Array
(
    [valid] => 1
    [number] => 5500005555555559
    [type] => mastercard
)

```

### Validate a card number and return the type:

[](#validate-a-card-number-and-return-the-type)

```
$card = CreditCard::validCreditCard('371449635398431');
print_r($card);
```

Output:

```
Array
(
    [valid] => 1
    [number] => 371449635398431
    [type] => amex
)

```

### Validate the CVC

[](#validate-the-cvc)

```
$validCvc = CreditCard::validCvc('234', 'visa');
var_dump($validCvc);
```

Output:

```
bool(true)

```

### Validate the expiration date

[](#validate-the-expiration-date)

```
$validDate = CreditCard::validDate('2013', '07'); // past date
var_dump($validDate);
```

Output:

```
bool(false)

```

Tests
-----

[](#tests)

Execute the following command to run the unit tests:

```
vendor/bin/phpunit

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1132d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/914e26b417db1ebc121668143451cd7ed40c47988c87491315cf6ad9d0c92fa7?d=identicon)[giahojnost](/maintainers/giahojnost)

---

Top Contributors

[![chelryong](https://avatars.githubusercontent.com/u/219942323?v=4)](https://github.com/chelryong "chelryong (5 commits)")

---

Tags

laravelvalidatorcreditcardcardcreditdebitcvccardscreditcards

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/giahojnost-credit-card-validator/health.svg)

```
[![Health](https://phpackages.com/badges/giahojnost-credit-card-validator/health.svg)](https://phpackages.com/packages/giahojnost-credit-card-validator)
```

###  Alternatives

[inacho/php-credit-card-validator

Validates popular debit and credit cards numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date

2051.4M11](/packages/inacho-php-credit-card-validator)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[jlorente/php-credit-cards

A PHP package to perform operations on debit and credit cards like format, validate brand, number and Luhn algorithm. It validates popular brands like Visa, Mastercard, American Express, etc.

44421.2k1](/packages/jlorente-php-credit-cards)[freelancehunt/php-credit-card-validator

Validates popular debit and credit cards' numbers against regular expressions and Luhn algorithm. Also validates the CVC and the expiration date.

18620.4k2](/packages/freelancehunt-php-credit-card-validator)[dragon-code/card-number

Generation and verification of card numbers using Luhn's algorithm.

6512.8k](/packages/dragon-code-card-number)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
