creditCard
Validates a credit card number using the Luhn checksum algorithm.
Options
| Option | Type | Default | Description |
|---|---|---|---|
message | string | locale default | Custom error message |
Playground
Valid values
| Value | Notes |
|---|---|
"4532015112830366" | Visa |
"5425233430109903" | Mastercard |
"378282246310005" | American Express |
Invalid values
| Value | Reason |
|---|---|
"4532015112830367" | Fails Luhn checksum |
"1234567890123456" | Not a valid card number |
Notes
- Empty string (
"") always returnsvalid: true— validators only run on non-empty values. Combine withnotEmptyto require a value. - Accepts digits with or without spaces/hyphens.