1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
rs-card-validate
================
[](https://github.com/valeriansaliou/rs-card-validate/actions?query=workflow%3A%22Test+and+Build%22) [](https://github.com/valeriansaliou/rs-card-validate/actions?query=workflow%3A%22Build+and+Release%22) [](https://www.buymeacoffee.com/valeriansaliou)
[Documentation](https://docs.rs/crate/card-validate)
[Crate](https://crates.io/crates/card-validate)
Detects and validates credit card numbers (type of card, number length and Luhn checksum).
**Important notice: this is a complete rework of [@rprotasov](https://github.com/rprotasov/creditcardvalidator) 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`:
```toml
[dependencies]
card-validate = "2.3"
```
## Validate a number
```rust
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)
}
```
|