isLuhnValid
Mask
stable
Validates a numeric string using the Luhn checksum algorithm (ISO/IEC 7812). Commonly used to verify credit card numbers, IMEI codes, and SIRET-like sequences.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- digitsrequiredstring
- A string containing only ASCII digits. Non-digit characters or empty strings return false immediately without running the checksum.
API
Return value
The value returned by this util.
- true when the digit string passes the Luhn mod-10 check; false for empty input, non-digit characters, or a bad checksum.
Usage
Examples
Ready-to-paste usage snippets.
Credit card number validation