valeriansaliou / rs-card-validate

:credit_card: Detects and validates credit card numbers (type of card, number length and Luhn checksum).
https://crates.io/crates/card-validate
MIT License
19 stars 6 forks source link
card crates credit-card rust rust-library

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:

Credit cards:

Install library

In your Cargo.toml:

[dependencies]
card-validate = "2.4"

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)
}