Checkdigit validate
checkdigit-validate · version 1.0.0 · Identifiers & check digits · free, no key needed
Validate a full value's trailing check digit(s) against a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).
Use when you need to: check if a luhn number is valid · validate an iso 7064 check digit · verhoeff checksum validator.
Decide before calling
Read the versioned contract and the supported scope below. Reuse checkdigit-validate@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use checkdigit-validate@1.0.0 for check if a luhn number is valid. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- check if a luhn number is valid
- validate an iso 7064 check digit
- verhoeff checksum validator
- does this gs1 barcode number pass its check digit
- verify a mod 97 check pair
- is this swiss mod 10 recursive reference valid
- בדיקת ספרת ביקורת
Not supported
- computing a check digit for a bare payload (use checkdigit-compute)
- identifier-specific structure such as IBAN country rules or ISIN prefixes
- auto-detecting the algorithm from the value shape
Behavior
- value must be a string of 1-66 characters; character-content problems are reported as valid:false with a reason, not thrown, because a badly-formed identifier is well-typed input that fails the check.
- check_len(algorithm) is 1 for luhn, verhoeff, damm, iso7064-mod11-2, iso7064-mod11-10, iso7064-mod37-2, iso7064-mod37-36, gs1-mod10 and mod10-recursive; 2 for iso7064-mod97-10, iso7064-mod661-26 and iso7064-mod1271-36.
- If value has check_len(algorithm) characters or fewer, return {valid:false, reason:'too_short', expected_check_digits:null}.
- Otherwise split value into payload (all but the last check_len characters) and given_check (the last check_len characters); a payload or given_check character outside the algorithm's alphabet returns {valid:false, reason:'invalid_character', expected_check_digits:null} (the check-alphabet also allows '*' for iso7064-mod37-2 check_value 36 and 'X' for iso7064-mod11-2 check_value 10).
- Otherwise compute expected_check_digits from payload using the same formulas as checkdigit-compute; exact string equality with given_check gives valid:true, reason:null, else valid:false, reason:"check_digit_mismatch", with expected_check_digits always the computed value.
Input
value(string, required): min length 1; max length 66algorithm(one of "luhn", "verhoeff", "damm", "iso7064-mod11-2", "iso7064-mod11-10", "iso7064-mod37-2", "iso7064-mod37-36", "iso7064-mod97-10", "iso7064-mod661-26", "iso7064-mod1271-36", "gs1-mod10", "mod10-recursive", required)
Output
valid(boolean, required)reason(one of null, "too_short", "invalid_character", "check_digit_mismatch", required)algorithm(one of "luhn", "verhoeff", "damm", "iso7064-mod11-2", "iso7064-mod11-10", "iso7064-mod37-2", "iso7064-mod37-36", "iso7064-mod97-10", "iso7064-mod661-26", "iso7064-mod1271-36", "gs1-mod10", "mod10-recursive", required)expected_check_digits(string or null, required): min length 1; max length 2
Limits
- max value bytes: 66
Example
Request input:
{
"value": "4111111111111111",
"algorithm": "luhn"
}
Response:
{
"result": {
"valid": true,
"reason": null,
"algorithm": "luhn",
"expected_check_digits": "1"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "checkdigit-validate",
"version": "1.0.0",
"input": {
"value": "4111111111111111",
"algorithm": "luhn"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/checkdigit-validate/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"4111111111111111","algorithm":"luhn"}'
The machine-readable contract is at /v1/tools/checkdigit-validate/versions/1.0.0.
CLI
node cli.mjs run checkdigit-validate 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Checkdigit compute: Compute the check digit(s) for a payload under a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).
- Gs1 key validate: Validate a GTIN-8/12/13/14, GLN, SSCC or GSIN's GS1 mod-10 check digit and look up its 3-digit GS1 prefix meaning.
- Lei validate: Validate a 20-character LEI's ISO/IEC 7064 MOD 97-10 check digits and parse its LOU prefix and entity part.
- Cas number validate: Validate a CAS Registry Number's position-weighted mod 10 check digit over its variable-length first segment.
- Isbn validate: Validate an ISBN-10 (mod 11, X allowed) or ISBN-13 (EAN mod 10) check digit and return the other form when it exists.
- Orcid validate: Validate a 16-digit ORCID iD or ISNI's ISO 7064 MOD 11-2 check character, accepting bare, grouped or URL forms.