credit_card_validator 0.0.2

credit_card_validator | Credit Card Validator #

A Dart package that validates credit card numbers, expiration dates, and security codes (CVV/CVC) based on the type of credit card

Installing #

  1. Add dependency to pubspec.yaml

    Get the current version in the 'Installing' tab on

    credit_card_validator: *current-version*
  1. Import the package
import 'package:credit_card_validator/credit_card_validator.dart';

Usage #

A basic example

Note: #

The CreditCardValidator class is meant to be used as a mixin and is not instantiable or extendable.

import 'package:credit_card_validator/credit_card_validator.dart';

class CreditCardValidationBloc with CreditCardValidator {
    // Your wrapper class for validating credit cards that now has access to validation functions
    // You can evaluate the results from the functions in your own functions inside this class

Features #

  • Supported cards:
    • Visa
    • Mastercard
    • American Express
    • Discover
    • More to come!

Author #

Tanner Davis (Cholojuanito) - Creator and repo owner - Github Profile

License #

This project is licensed under the MIT License - see the LICENSE file for more details

Up next #

  • Security code validation and unit tests

[0.0.2] - April 18, 2019

  • Expiration date validation
    • Allows for dates with the following formats:
      • MM/YYYY
      • MM/YYY will only happen when the user is typing in a 4 digit year
      • MM/YY
    • Also makes sure the expiration year isn't beyond a certain limit, default is 19

[0.0.1] - April 15, 2019

  • Initial release
  • Card number validation supported for:
    • Visa
    • American Express
    • Discover
    • MasterCard


Example usage #

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  credit_card_validator: ^0.0.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:credit_card_validator/credit_card_validator.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
credit_card_type_detector ^1.0.1 1.1.0
Dev dependencies
test ^1.5.3