#credit-card #numbers #provider

card-validate

Rust card validate detects and validates credit card numbers

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

#52 in Value formatting

Download history 3054/week @ 2024-12-10 1798/week @ 2024-12-17 895/week @ 2024-12-24 1248/week @ 2024-12-31 1988/week @ 2025-01-07 2026/week @ 2025-01-14 2262/week @ 2025-01-21 2318/week @ 2025-01-28 2994/week @ 2025-02-04 2951/week @ 2025-02-11 2745/week @ 2025-02-18 3122/week @ 2025-02-25 3425/week @ 2025-03-04 3163/week @ 2025-03-11 2973/week @ 2025-03-18 3245/week @ 2025-03-25

13,269 downloads per month
Used in 15 crates (10 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