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

#28 in Value formatting

Download history 2934/week @ 2024-07-28 2872/week @ 2024-08-04 2022/week @ 2024-08-11 2307/week @ 2024-08-18 2143/week @ 2024-08-25 2620/week @ 2024-09-01 3201/week @ 2024-09-08 2852/week @ 2024-09-15 2986/week @ 2024-09-22 3001/week @ 2024-09-29 2933/week @ 2024-10-06 2297/week @ 2024-10-13 3083/week @ 2024-10-20 2922/week @ 2024-10-27 3037/week @ 2024-11-03 2877/week @ 2024-11-10

11,986 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