# Framework-free validation (laravel-rust-credit-card)

> The core crate validates card numbers, security codes, and expiration dates with an explicit clock for date checks.

- Package: laravel-rust-credit-card (Laravel for Rust, alpha), crates: `laravel-rust-credit-card`, `laravel-rust-credit-card-core`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-credit-card), [crates.io](https://crates.io/crates/laravel-rust-credit-card/0.1.0), [docs.rs](https://docs.rs/laravel-rust-credit-card/0.1.0), [Changelog](https://oss.bowerbird.si/credit-card/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-credit-card/blob/aa74b5cf59bf07f77714c9f308a7a47bb62633c4/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-credit-card/blob/aa74b5cf59bf07f77714c9f308a7a47bb62633c4/SECURITY.md)
- Based on: [laravel-validation-rules/credit-card](https://github.com/laravel-validation-rules/credit-card): The PHP validation rules whose behaviour this package independently implements, following version 1.12.3.
- PHP parity: full (30 covered, 12 diverged, 0 planned of 42 abilities; 830 fixtures; follows laravel-validation-rules/credit-card 1.12.3; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/credit-card/docs/core/
- Source: https://github.com/bowerbird-si/laravel-rust-credit-card/blob/aa74b5cf59bf07f77714c9f308a7a47bb62633c4/docs/core.md

The core crate validates card numbers, security codes, and expiration dates with an explicit clock for date checks.

```toml
[dependencies]
laravel-rust-credit-card-core = "0.1"
```

```rust
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`.
