The core crate validates card numbers, security codes, and expiration dates with an explicit clock for date checks.
[dependencies]
laravel-rust-credit-card-core = "0.1"use laravel_rust_credit_card_core::{Brand, Card, YearMonth};
let card = Card::parse("4111000000000008")?;
assert_eq!(card.brand(), Brand::Visa);
assert!(card.is_valid_cvc("012"));
let today = YearMonth::new(2026, 12)?;
let expiration = YearMonth::parse("26", "12", today)?;
assert_eq!(expiration, today);
Use Brand::Visa.parse to validate against a known brand and passes_luhn to check a sequence
of ASCII digits. Automatic detection follows Brand::ALL and validates against the first matching brand.
Union Pay accepts its supported lengths without checking the Luhn checksum.
Use ExpirationFormat::new("m/y") to compile a format for repeated use. The parser supports Y,
y, m, n, M, F, d, j, H, i, s, and escaped literals.
For a custom brand, set its prefixes, number lengths, and security code lengths with
CardSpec::builder, then use CardSpec::validate and CardSpec::is_valid_cvc.