# Swiss qr reference validate

`swiss-qr-reference-validate` · version 1.0.0 · Identifiers & check digits · free, no key needed

Validate a 27-digit Swiss QR-bill QR reference's modulo-10-recursive check digit and reject all-zero references.

**Use when you need to: validate a swiss qr bill reference number · check digit for a qrr reference · is this qr-bill reference valid.**

## Decide before calling

Read the [versioned contract](/v1/tools/swiss-qr-reference-validate/versions/1.0.0) and the supported scope below. Reuse `swiss-qr-reference-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 `swiss-qr-reference-validate@1.0.0` for validate a swiss qr bill reference number. 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

- validate a swiss qr bill reference number
- check digit for a qrr reference
- is this qr-bill reference valid
- verify a swiss payment slip reference before sending
- modulo 10 recursive check digit for a qr reference
- esr qrr reference checksum

## Not supported

- the Swiss ISR/ESR 27-character reference of the older, non-QR payment slip format documented separately (same algorithm, but this tool only accepts the QR-bill QRR 27-digit shape)
- computing a new QR reference from a payload (this tool only validates)
- creditor information, IBAN/QR-IBAN, amount or debtor fields printed on the same QR-bill

## Behavior

- Every ASCII space is removed from reference first; no other trimming and no case folding.
- If the space-stripped string's length is not 27 code points, valid:false, reason:'wrong_length', normalized:null, check_digit:null, print:null.
- Otherwise, if the space-stripped string does not match ^[0-9]{27}$, valid:false, reason:'invalid_character', normalized:null, check_digit:null, print:null.
- Otherwise normalized = the 27-digit string. print = normalized split into groups of 2,5,5,5,5,5 digits joined by a single space. check_digit = normalized[26] (echoed as given, not recomputed); these three fields are populated from here on regardless of validity.
- If normalized is 27 zero digits, valid:false, reason:'all_zero' (checked before the checksum, since an all-zero reference's checksum would otherwise pass).
- Modulo 10 recursive check: walk the first 26 digits with the mod10-recursive carry table (shared with checkdigit-compute/validate); expected_check_digit = (10 - carry) mod 10. If check_digit differs, valid:false, reason:"check_digit_mismatch". Otherwise valid:true, reason:null.

## Input

- `reference` (string, required): min length 1; max length 40

## Output

- `valid` (boolean, required)
- `reason` (one of null, "wrong_length", "invalid_character", "all_zero", "check_digit_mismatch", required)
- `normalized` (string or null, required): pattern `^[0-9]{27}$`
- `check_digit` (string or null, required): pattern `^[0-9]$`
- `print` (string or null, required): min length 32; max length 32

## Limits

- max reference bytes: 40

## Example

Request input:

```json
{
  "reference": "210000000003139471430009017"
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "normalized": "210000000003139471430009017",
    "check_digit": "7",
    "print": "21 00000 00003 13947 14300 09017"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "swiss-qr-reference-validate",
  "version": "1.0.0",
  "input": {
    "reference": "210000000003139471430009017"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/swiss-qr-reference-validate/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"reference":"210000000003139471430009017"}'
```

The machine-readable contract is at [/v1/tools/swiss-qr-reference-validate/versions/1.0.0](/v1/tools/swiss-qr-reference-validate/versions/1.0.0).

### CLI

```sh
node cli.mjs run swiss-qr-reference-validate 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Checkdigit validate](/tools/checkdigit-validate): Validate a full value's trailing check digit(s) against a named algorithm (Luhn, Verhoeff, Damm, ISO 7064, GS1, mod 10).
- [Imo number validate](/tools/imo-number-validate): Validate a 7-digit IMO ship identification number's weighted mod-10 check digit, with or without the 'IMO ' prefix.
- [Isin validate](/tools/isin-validate): Validate a 12-character ISIN's ISO 6166 Luhn check digit and parse its country prefix, NSIN and NSIN scheme.
- [Iso6346 container validate](/tools/iso6346-container-validate): Validate an 11-character ISO 6346 container number's mod-11 check digit and split the owner code, category and serial.
- [Mx clabe validate](/tools/mx-clabe-validate): Validate an 18-digit Mexican CLABE's weighted check digit and split it into bank, plaza and account fields.
- [Uk nhs number validate](/tools/uk-nhs-number-validate): Validate a 10-digit NHS number's modulus 11 check digit (NHS Data Dictionary); 11 minus remainder = 10 is never valid.
