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

#32 in Value formatting

Download history 3200/week @ 2024-09-18 2843/week @ 2024-09-25 3274/week @ 2024-10-02 2357/week @ 2024-10-09 2997/week @ 2024-10-16 2827/week @ 2024-10-23 2908/week @ 2024-10-30 3035/week @ 2024-11-06 2849/week @ 2024-11-13 2506/week @ 2024-11-20 2636/week @ 2024-11-27 2469/week @ 2024-12-04 2935/week @ 2024-12-11 1610/week @ 2024-12-18 811/week @ 2024-12-25 1142/week @ 2025-01-01

6,983 downloads per month
Used in 12 crates (9 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–3MB
~54K SLoC