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

#29 in Value formatting

Download history 3512/week @ 2024-04-05 2831/week @ 2024-04-12 3111/week @ 2024-04-19 2807/week @ 2024-04-26 2534/week @ 2024-05-03 2624/week @ 2024-05-10 2322/week @ 2024-05-17 2276/week @ 2024-05-24 1967/week @ 2024-05-31 3305/week @ 2024-06-07 2194/week @ 2024-06-14 2129/week @ 2024-06-21 2217/week @ 2024-06-28 2401/week @ 2024-07-05 2759/week @ 2024-07-12 2875/week @ 2024-07-19

10,594 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
~54K SLoC