19 stable releases

2.4.0 Mar 30, 2024
2.3.0 Apr 3, 2023
2.2.3 Jan 8, 2023
2.2.2 Feb 19, 2019
0.2.2 Aug 27, 2017

#30 in Value formatting

Download history 2269/week @ 2024-08-17 2201/week @ 2024-08-24 2604/week @ 2024-08-31 3179/week @ 2024-09-07 2855/week @ 2024-09-14 3033/week @ 2024-09-21 2972/week @ 2024-09-28 2926/week @ 2024-10-05 2345/week @ 2024-10-12 3052/week @ 2024-10-19 2906/week @ 2024-10-26 3015/week @ 2024-11-02 3006/week @ 2024-11-09 2595/week @ 2024-11-16 2345/week @ 2024-11-23 2444/week @ 2024-11-30

11,057 downloads per month
Used in 12 crates (8 directly)

MIT license

11KB
202 lines

rs-card-validate

Test and Build Build and Release Buy Me A Coffee

Documentation

Crate

Detects and validates credit card numbers (type of card, number length and Luhn checksum).

Important notice: this is a complete rework of @rprotasov initial work, supporting more card providers and containing important validation fixes.

🇫🇷 Crafted in Brest, France.

Supported providers

Debit cards:

  • Visa Electron
  • Maestro
  • Forbrugsforeningen
  • Dankort

Credit cards:

  • Visa
  • MasterCard
  • American Express
  • MIR
  • Diners Club
  • Discover
  • UnionPay
  • JCB

Install library

In your Cargo.toml:

[dependencies]
card-validate = "2.3"

Validate a number

extern crate card_validate;

use card_validate::Validate;

let card_number = "5236313877109142";

match Validate::from(card_number) {
  Ok(result) => println!("Card type is: {}", result.card_type.name()),
  Err(err) => println!("Card is invalid: {:?}", err)
}

Dependencies

~2.2–3MB
~55K SLoC