Card number check
FreeLogic@rabbinatix/card-number-check by Rabbinatixupdated Oct 4, 2026
The Luhn checksum that catches mistyped card numbers.
From the right, every second digit is doubled (minus 9 when over 9) and all digits are added; valid numbers add up to a multiple of 10. A For Loop walks the digits and Call Function works out each one in a helper function.
Shows: For Loop, Call Function with several inputs, a running total Variable, Regex Match.
How to use it
Add it to your logic, then add a Call Function step in any logic and pick Card number check. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.
Inputs
number: Text
Outputs
valid: Yes / No
Previewdrag the steps around; scroll to zoom
Function Entry, Input / output. 0 inputs, 2 outputs. step 1 of 17
Card number check
number
Replace, String. 3 inputs, 1 output. step 2 of 17
Replace
text
search
replacement
result
String Length, String. 1 input, 1 output. step 3 of 17
String Length
text
length
Subtract, Operators. 2 inputs, 1 output. step 4 of 17
-
A
B
result
For Loop, Flow control. 3 inputs, 3 outputs. step 5 of 17
For Loop
first
last
Loop Body
index
Completed
Subtract, Operators. 2 inputs, 1 output. step 6 of 17
-
A
B
result
Modulo, Operators. 2 inputs, 1 output. step 7 of 17
%
A
B
result
Equals, Operators. 2 inputs, 1 output. step 8 of 17
==
A
B
result
Call Function, Functions. 4 inputs, 2 outputs. step 9 of 17
Luhn digit
text
position
double
value
Get Variable, Data. 0 inputs, 1 output. step 10 of 17
Get sum
value
Add, Operators. 2 inputs, 1 output. step 11 of 17
+
A
B
result
Set Variable, Data. 2 inputs, 2 outputs. step 12 of 17
Set sum
value
value
Modulo, Operators. 2 inputs, 1 output. step 13 of 17
%
A
B
result
Equals, Operators. 2 inputs, 1 output. step 14 of 17
==
A
B
result
Regex Match, String. 1 input, 2 outputs. step 15 of 17
Regex Match
text
matches
groups
AND, Operators. 2 inputs, 1 output. step 16 of 17
AND
A
B
result
Return, Input / output. 2 inputs, 0 outputs. step 17 of 17
Return
valid
Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.
Examplesrun live against the logic · 3/3 pass
| Passed | Example | Input | Output |
|---|---|---|---|
| A valid test card | {"number":"4111 1111 1111 1111"} | {"valid":true} | |
| One digit off | {"number":"4111 1111 1111 1112"} | {"valid":false} | |
| Not digits | {"number":"4111-abcd"} | {"valid":false} |
Try it
Versions
In this package
Card number check (entry)
Luhn digit
