# Cas number validate

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

Validate a CAS Registry Number's position-weighted mod 10 check digit over its variable-length first segment.

**Use when you need to: validate a cas number · check cas registry number check digit · is this cas rn valid.**

## Decide before calling

Read the [versioned contract](/v1/tools/cas-number-validate/versions/1.0.0) and the supported scope below. Reuse `cas-number-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 `cas-number-validate@1.0.0` for validate a cas 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 cas number
- check cas registry number check digit
- is this cas rn valid
- cas checksum validator
- verify a chemical registry number
- confirm a cas number format
- does this chemical registry number pass its check digit

## Not supported

- looking up which chemical substance a CAS Registry Number actually identifies
- generating a fresh, unused CAS Registry Number
- accepting a leading zero in the first segment (never used in a real CAS RN)

## Behavior

- cas must match exactly: 2 to 7 digits not starting with '0', a literal '-', exactly 2 digits, a literal '-', exactly 1 digit (the check digit). Any deviation is reason wrong_format, checked first; every field is null in that case.
- normalized and check_digit (the raw final digit) are populated whenever cas matches the shape, regardless of whether the check digit itself is correct; normalized equals cas unchanged.
- Check digit: concatenate the first two groups (no hyphen) into a 4-9 digit string, reverse it, multiply each digit by its 1-based position in the reversed string (the digit immediately before the final hyphen has weight 1), sum the products, and take the result modulo 10. A mismatch is reason check_digit_mismatch.
- valid is true only when the shape and the check digit both pass, in that order; only one reason is ever returned.

## Input

- `cas` (string, required): min length 1; max length 12

## Output

- `valid` (boolean, required)
- `reason` (one of null, "wrong_format", "check_digit_mismatch", required)
- `normalized` (string or null, required)
- `check_digit` (string or null, required): min length 1; max length 1

## Limits

- max cas bytes: 12

## Example

Request input:

```json
{
  "cas": "50-78-2"
}
```

Response:

```json
{
  "result": {
    "valid": true,
    "reason": null,
    "normalized": "50-78-2",
    "check_digit": "2"
  }
}
```

## How to call it

### MCP

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

```json
{
  "id": "cas-number-validate",
  "version": "1.0.0",
  "input": {
    "cas": "50-78-2"
  }
}
```

### HTTP (no key)

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

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

### CLI

```sh
node cli.mjs run cas-number-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.
- [Lei validate](/tools/lei-validate): Validate a 20-character LEI's ISO/IEC 7064 MOD 97-10 check digits and parse its LOU prefix and entity part.
- [Isbn validate](/tools/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.
- [Ismn validate](/tools/ismn-validate): Validate an ISMN's EAN mod 10 check digit in M-form or 979-0 form and return the canonical 13-digit form.
- [Sedol validate](/tools/sedol-validate): Validate a 7-character SEDOL's weighted modulus 10 check digit and report whether it is a legacy all-numeric code.
