LUHN_CHECK
All functions > STRING > LUHN_CHECK
Returns TRUE if a string passes the Luhn algorithm (modulus 10 checksum).
Signatures
Returns: TRUE if the string passes the Luhn check, FALSE otherwise
LUHN_CHECK(string: VARCHAR) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | String of digits to validate |
Notes
- Commonly used for validating credit card numbers
- Non-digit characters (spaces, hyphens) are typically ignored
- Also known as mod 10 algorithm
- Returns FALSE for invalid input
Examples
FeatureQL
SELECT
f1 := LUHN_CHECK('4532015112830366'), -- Valid Visa card number
f2 := LUHN_CHECK('6011514433546201'), -- Valid Discover card
f3 := LUHN_CHECK('1234567890123456'), -- Invalid card number
f4 := LUHN_CHECK('79927398713'), -- Valid Luhn number
f5 := LUHN_CHECK('79927398710'), -- Invalid Luhn number
f6 := LUHN_CHECK('4532-0151-1283-0366') -- Valid with separators
;Result
| f1 BOOLEAN | f2 BOOLEAN | f3 BOOLEAN | f4 BOOLEAN | f5 BOOLEAN | f6 BOOLEAN |
|---|---|---|---|---|---|
| true | true | false | true | false | true |
On this page