#card #validation #credit-card #card-types

credit_card_types

Detect credit card types by number

4 releases

0.1.200 Jan 6, 2024
0.1.121 Jan 3, 2024
0.1.120 Dec 10, 2023
0.1.100 Aug 5, 2023

#109 in Finance

Download history 12/week @ 2024-08-26 101/week @ 2024-09-02 131/week @ 2024-09-09 68/week @ 2024-09-16 103/week @ 2024-09-23 106/week @ 2024-09-30 50/week @ 2024-10-07 41/week @ 2024-10-14 84/week @ 2024-10-21 93/week @ 2024-10-28 221/week @ 2024-11-04

441 downloads per month

MIT license

21KB
444 lines

Credit Card Types

Rust Workflow

The Credit Card Type library for Rust provides a utility method to determine the type of credit card based on both fully qualified and partial card numbers.

Features

  • Determine the type of credit card based on the provided card number (fully qualified or partial).
  • Support for popular credit card types like Visa, MasterCard, American Express, Discover, and more.
  • No dependencies.

Usage

use credit_card_types::{CreditCardPool, CreditCardType};

fn main() {
    // Create a new pool.
    let pool = CreditCardPool::new();

    // Get the credit card type for a given card number.
    let result = pool.get_credit_card_type("4111111111111111").unwrap();

    // Print the result.
    println!("Credit card type: {:#?}", result);
}

This crate was inspired by the credit-card-type NPM package.

License

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

No runtime deps