17 stable releases

2.2.3 Jan 8, 2023
2.2.2 Feb 19, 2019
2.2.1 May 22, 2018
2.2.0 Mar 30, 2018
0.2.2 Aug 27, 2017

#19 in Value formatting

Download history 216/week @ 2022-10-08 245/week @ 2022-10-15 210/week @ 2022-10-22 187/week @ 2022-10-29 319/week @ 2022-11-05 217/week @ 2022-11-12 250/week @ 2022-11-19 174/week @ 2022-11-26 183/week @ 2022-12-03 169/week @ 2022-12-10 178/week @ 2022-12-17 57/week @ 2022-12-24 99/week @ 2022-12-31 300/week @ 2023-01-07 291/week @ 2023-01-14 223/week @ 2023-01-21

916 downloads per month
Used in 5 crates (3 directly)

MIT license

11KB
181 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
  • Diners Club
  • Discover
  • UnionPay
  • JCB

Install library

In your Cargo.toml:

[dependencies]
card-validate = "2.1"

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

~1–1.3MB
~38K SLoC