# Lei validate

`lei-validate` · version 1.0.0 · Identifiers & check digits · free, no key needed

Validate a 20-character LEI's ISO/IEC 7064 MOD 97-10 check digits and parse its LOU prefix and entity part.

**Use when you need to: validate a legal entity identifier · check lei check digits · is this lei number valid.**

## Decide before calling

Read the [versioned contract](/v1/tools/lei-validate/versions/1.0.0) and the supported scope below. Reuse `lei-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 `lei-validate@1.0.0` for validate a legal entity identifier. 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 legal entity identifier
- check lei check digits
- is this lei number valid
- lei checksum validator
- parse lei lou prefix and entity part
- verify iso 17442 identifier
- does this lei pass mod 97

## Not supported

- looking up which entity an LEI actually identifies (no GLEIF lookup)
- checking an LEI is currently active, lapsed or duplicated in the GLEIF database
- validating a bare Modulus 97-10 string with no LEI structure (see checkdigit-validate)

## Behavior

- lei must be exactly 20 characters: no case folding, no trimming. Any other length is reason wrong_length, checked first.
- lou_prefix (characters 1-4), entity_part (5-18) and check_digits (19-20) are the raw positional substrings whenever lei is exactly 20 characters, regardless of charset or check-digit validity; all three are null only when length already failed.
- Characters 1-18 must each be a digit or an uppercase letter; characters 19-20 must each be a digit, else reason invalid_character.
- Check: expand all 20 characters to decimal digits (A=10...Z=35), concatenate, and take the remainder modulo 97 one digit at a time; the LEI is valid only when the remainder equals 1 (the ISO/IEC 7064 MOD 97-10 self-check property). Any other remainder is reason check_digit_mismatch.
- valid is true only when length, charset and the MOD 97-10 remainder all pass, in that order; only one reason is ever returned.

## Input

- `lei` (string, required): min length 1; max length 20

## Output

- `valid` (boolean, required)
- `reason` (one of null, "wrong_length", "invalid_character", "check_digit_mismatch", required)
- `lou_prefix` (string or null, required): min length 4; max length 4
- `entity_part` (string or null, required): min length 14; max length 14
- `check_digits` (string or null, required): min length 2; max length 2

## Limits

- max lei bytes: 20

## Example

Request input:

```json
{
  "lei": "HWUPKR0MPOU8FGXBT394"
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "lou_prefix": "HWUP",
    "entity_part": "KR0MPOU8FGXBT3",
    "check_digits": "94"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "lei-validate",
  "version": "1.0.0",
  "input": {
    "lei": "HWUPKR0MPOU8FGXBT394"
  }
}
```

### HTTP (no key)

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

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

### CLI

```sh
node cli.mjs run lei-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).
- [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.
- [Cas number validate](/tools/cas-number-validate): Validate a CAS Registry Number's position-weighted mod 10 check digit over its variable-length first segment.
- [Figi validate](/tools/figi-validate): Validate a 12-character FIGI's structure, forbidden-prefix rule and Modulus 10 Double Add Double check digit.
- [Iccid validate](/tools/iccid-validate): Validate a 19/20-digit ICCID's Luhn check digit, require the 89 major industry id, split issuer/account digits.
- [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.
