Standalone check-digit algorithms (Luhn, Verhoeff, ISO 7064), usable directly when you need the primitive rather than a typed identifier validator.
Each algorithm has a *-valid? predicate over a complete string (payload plus
the trailing check character). Where it applies, an algorithm also has a
*-check-digit or *-check calculator. The calculator returns the check
character for a bare payload.
(luhn-valid? "79927398713") ;=> true
(luhn-check-digit "7992739871") ;=> "3"
(iso7064-mod11-2-check "000000021825009") ;=> "7" (ORCID)
Standalone check-digit algorithms (Luhn, Verhoeff, ISO 7064), usable directly
when you need the primitive rather than a typed identifier validator.
Each algorithm has a `*-valid?` predicate over a complete string (payload plus
the trailing check character). Where it applies, an algorithm also has a
`*-check-digit` or `*-check` calculator. The calculator returns the check
character for a bare payload.
(luhn-valid? "79927398713") ;=> true
(luhn-check-digit "7992739871") ;=> "3"
(iso7064-mod11-2-check "000000021825009") ;=> "7" (ORCID)(ean13-check-digit payload)The EAN-13 check digit for a twelve-digit payload.
The EAN-13 check digit for a twelve-digit `payload`.
(iso7064-mod11-2-check payload)The ISO 7064 Mod 11-2 check character for the digit string payload, as
"0"-"9" or "X".
The ISO 7064 Mod 11-2 check character for the digit string `payload`, as "0"-"9" or "X".
(iso7064-mod11-2-valid? s)True if s (digits plus a final "0"-"9"/"X" check character) is valid
under ISO 7064 Mod 11-2.
True if `s` (digits plus a final "0"-"9"/"X" check character) is valid under ISO 7064 Mod 11-2.
(iso7064-mod37-36-check payload)(iso7064-mod37-36-check payload alphabet)Return the ISO 7064 Mod 37,36 check character for payload.
An optional alphabet turns this into the corresponding Mod x+1,x variant.
Return the ISO 7064 Mod 37,36 check character for `payload`. An optional alphabet turns this into the corresponding Mod x+1,x variant.
(iso7064-mod37-36-valid? s)(iso7064-mod37-36-valid? s alphabet)True if s has a valid ISO 7064 Mod 37,36 check character.
An optional alphabet turns this into the corresponding Mod x+1,x variant.
True if `s` has a valid ISO 7064 Mod 37,36 check character. An optional alphabet turns this into the corresponding Mod x+1,x variant.
(iso7064-mod97-10-valid? s)True if the alphanumeric string s (letters A-Z taken as 10-35, check digits
included) is valid under ISO 7064 Mod 97-10: its running remainder is 1.
This is the LEI and IBAN style of checksum.
True if the alphanumeric string `s` (letters A-Z taken as 10-35, check digits included) is valid under ISO 7064 Mod 97-10: its running remainder is 1. This is the LEI and IBAN style of checksum.
(luhn-check-digit payload)The Luhn check digit (a one-character string) for the bare payload digit
string payload.
The Luhn check digit (a one-character string) for the bare payload digit string `payload`.
(luhn-valid? s)True if the digit string s (payload plus its trailing check digit) satisfies
the Luhn checksum. Non-digit input returns false and does not throw.
True if the digit string `s` (payload plus its trailing check digit) satisfies the Luhn checksum. Non-digit input returns false and does not throw.
(verhoeff-check-digit payload)The Verhoeff check digit (a one-character string) for payload.
The Verhoeff check digit (a one-character string) for `payload`.
(verhoeff-valid? s)True if the digit string s (payload plus check digit) satisfies the Verhoeff
checksum. Non-digit input returns false.
True if the digit string `s` (payload plus check digit) satisfies the Verhoeff checksum. Non-digit input returns false.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |