Identifier Codes

Card numbers, tax IDs, VINs, bank accounts, barcodes and book numbers all follow published formats, and most of them end in a check digit: a digit computed from the others, so that a mistyped digit shows up. Summer knows 48 of these formats. You name the one you expect, and Summer applies the right rules. You never need to know which algorithm sits underneath.

Two functions use these codes:

Jump to the list of codes.

Checking values with VALIDATE

VALIDATE({VIN}, "vin")
VALIDATE({Card Number}, "credit_card", "bool")

The third argument is optional and chooses what an invalid value gives:

ValueDefault ("error")With "bool"
Blankblankblank
Validtruetrue
Invalidan error saying whyfalse

By default an invalid value is an error, so you can see what is wrong. Use "bool" to filter or count: VALIDATE({Card}, "credit_card", "bool") in a filter shows only the good rows, and its negation shows only the bad ones. The error message names the code and the problem:

A misspelled code, like VALIDATE(x, "vinn"), is an error on every row, so it can't pass unnoticed.

What "valid" means

Every code is one of two kinds. The list says which for each code:

Neither kind means the number exists. A valid card number may never have been issued, and a valid VIN may belong to no car. A check digit means "no typo detected", not "this is real".

VINs from outside North America often don't use the check digit, so vin can reject a perfectly good European or Asian VIN. Use vin_structure for those: it checks everything except the check digit.

What Summer accepts

Masked card numbers

Exports and receipts often hide all but the last four digits. These can't be checked with credit_card, because the check digit is hidden too. Use credit_card_masked, which checks that the value is a sensibly masked card. Accepted forms:

Exactly four digits must show at the end. Leading digits, if shown, must belong to a known card network and agree with any brand word. When the whole layout is written out, its length must be one that network issues.

Reading parts with GET

GET({VIN}, "vin:model_year")        → 1989
GET({IBAN}, "iban:country")         → GBR
GET({Card}, "credit_card:last4")    → 1111
GET({Card}, "credit_card:brand")    → Visa

Write the part with its code in front (vin:, iban:). The list of codes below shows the parts each one has. Some things to know:

An SSN's state

GET("078-05-1120", "ssn:state_guess")  → NY

Until June 25, 2011, the first three digits of an SSN (the area) came from the state on the application's mailing address. Before 1973 it was the state of the local Social Security office. It was never the state of birth. Since then SSNs have been assigned at random, so the area says nothing. ssn:state_guess gives the two-letter state or territory code the area belonged to. It is a guess because the number itself doesn't say when it was issued. A newer number that lands in an old area gets the old area's state.

Summer leaves it blank when the number can't have been issued before 2011:

It is also blank for areas that never meant a state: 700–728 (Railroad Retirement Board, until 1963), 729–733 (issued to immigrants on entry), and the parts of 586 used for the Philippines and Americans working abroad. Area 232 is West Virginia except group 30 (North Carolina); 580 is the Virgin Islands for groups 01–18 and Puerto Rico after; 586 is Guam for groups 01–18 and American Samoa for 20–28. The tables are SSA's own, built into Summer.

Check digits

Every code verified by a check digit has two more parts:

GET("1M8GDM9A1KP042788", "vin:check_digit")           → 1
GET("1M8GDM9A1KP042788", "vin:check_digit_expected")  → X
GET("400638133393", "ean_13:check_digit_expected")    → 1
GET("7992739871", "luhn:check_digit_expected")        → 3

These help you repair a mistyped value, or build test data: write the digits, then append check_digit_expected.

Finding identifiers in text with DETECT

DETECT(text, "credit_card"), "iban" and "uuid" count the identifiers inside longer text, like a note or a log line. Each candidate must pass the same checks as VALIDATE, so a 16-digit order number isn't counted as a card. A card number is not also counted as a phone number.

DETECT({Notes}, "credit_card")   → 2
DETECT({Notes})                  → "credit_card, email, phone"

Sensitive columns

When a file loads, Summer masks a column that looks like personal financial data, so it isn't on screen by accident. Use Unset Sensitive (⌃8) to show it. A column is masked when:

Masked card numbers (****1234), phone numbers, routing numbers and barcodes never mask a column.

Trying it on sample data

Summer's sample data (⌘0) has a Validation column with good and bad examples of every code, written value | group:code, for example 1M8GDM9AXKP042788 | everyday:vin. To see every verdict and every error message, add this column:

VALIDATE(SPLIT({Validation}, "|", 1), SPLIT({Validation}, "|", 2), "error")

The codes

The codes are grouped the way the formula editor lists them. Start typing a code or a plain word ("barcode", "bank", "book", "tax") and the editor finds it.

Everyday

The identifiers most US data holds: payment cards, tax numbers, bank routing, phones, email, vehicles, barcodes, books and UUIDs.

CodeWhat it checksVerified by
credit_card
Credit card number
A full card number: 12–19 digits, spaces or dashes allowed, optionally after a brand word (Visa 4111 1111 1111 1111). The prefix must belong to a known card network, the length must be one that network issues, and the Luhn check digit must match. A brand word must agree with the prefix.
Example: 4111 1111 1111 1111
GET parts: credit_card:brand, credit_card:last4, credit_card:masked, credit_card:iin, credit_card:check_digit, credit_card:check_digit_expected
check digit
credit_card_masked
Credit card, masked (last 4)
A card shown with its digits hidden: ****-****-****-1234, XXXX1234, •••• 1234, ...1234, 411111******1111 (first 6 and last 4), "ending in 1234", with an optional brand word (Visa, MC, Amex …). Exactly the last 4 digits visible. Visible leading digits must belong to a known network and agree with a brand word; a fully written layout must have a length that network issues.
Example: Visa ****1234
GET parts: credit_card_masked:brand, credit_card_masked:last4, credit_card_masked:masked, credit_card_masked:iin
format only
ssn
Social Security number (US)
123-45-6789 or 123456789. Area not 000, 666 or 900–999; group not 00; serial not 0000. Format only: a well-formed number may still never have been issued.
Example: 078-05-1120
GET parts: ssn:state_guess, ssn:masked, ssn:area, ssn:group, ssn:serial
format only
ein
Employer ID / EIN (US)
12-3456789 or 123456789, with a prefix the IRS assigns. Format only.
Example: 12-3456789
format only
routing_number
Bank routing number (US, ABA)
9 digits. The first two must be an assigned range (00 government, 01–12 Federal Reserve district, 21–32 thrift, 61–72 electronic, 80 traveler's checks), and the 3-7-1 weighted check must pass.
Example: 011000015
GET parts: routing_number:fed_district, routing_number:check_digit, routing_number:check_digit_expected
check digit
phone
Phone number (any)
Anything a Phone column accepts: 7–15 digits in phone punctuation, an optional +country code and extension. Format only.
Example: (615) 555-1212
format only
phone_us
Phone, US/Canada (NANP)
10 digits, or 11 starting with 1, in any phone punctuation. Area code and exchange start with 2–9, and the area code is not an N11 service code. Format only.
Example: 615-555-1212
format only
phone_e164
Phone, international format (E.164)
+ then 2–15 digits with no spaces or punctuation, starting with an assigned country calling code (+16155551212). Format only.
Example: +16155551212
format only
email
Email address
[email protected] — the same test an Email column uses. A practical check, not full RFC 5322. Format only.
Example: [email protected]
format only
zip
ZIP code (US)
12345 or ZIP+4 12345-6789 — the same test a ZIP Code column uses. Format only.
Example: 37203-1234
format only
vin
Vehicle ID (VIN)
17 letters and digits, never I, O or Q, with the North American check digit in position 9 (49 CFR 565). VINs from elsewhere often have no check digit: use vin_structure for those.
Example: 1M8GDM9AXKP042788
GET parts: vin:model_year, vin:manufacturer, vin:country, vin:region, vin:wmi, vin:plant, vin:serial, vin:vds, vin:check_digit, vin:check_digit_expected
check digit
vin_structure
Vehicle ID (VIN), any country
17 letters and digits, never I, O or Q, with a valid model-year character in position 10. Does not check the check digit, so it accepts VINs from anywhere. Format only.
Example: WVWZZZ1JZXW000001
GET parts: vin:model_year, vin:manufacturer, vin:country, vin:region, vin:wmi, vin:plant, vin:serial, vin:vds, vin:check_digit, vin:check_digit_expected
format only
upc
UPC barcode
12 digits with a GS1 check digit. Spaces and dashes allowed.
Example: 036000291452
GET parts: upc:gs1_prefix_country, upc:gtin14, upc:check_digit, upc:check_digit_expected
check digit
isbn
Book number (ISBN)
ISBN-10 or ISBN-13, with or without hyphens or an "ISBN" prefix. ISBN-13 starts 978 or 979.
Example: 978-0-306-40615-7
GET parts: isbn:to_13, isbn:to_10, isbn:prefix, isbn:check_digit, isbn:check_digit_expected
check digit
uuid
UUID / GUID
8-4-4-4-12 hex digits, either case, optionally in {braces} or after urn:uuid: — the same test a UUID column uses. Any version or variant. Format only.
Example: 123e4567-e89b-42d3-a456-426614174000
format only

Products & publishing

GS1 barcodes in every length, and the book and serial numbers.

CodeWhat it checksVerified by
isbn_10
ISBN-10
9 digits and a check character (0–9 or X), hyphens allowed.
Example: 0-306-40615-2
GET parts: isbn_10:to_13, isbn_10:to_10, isbn_10:prefix, isbn_10:check_digit, isbn_10:check_digit_expected
check digit
isbn_13
ISBN-13
13 digits starting 978 or 979, hyphens allowed, GS1 check digit.
Example: 978-0-306-40615-7
GET parts: isbn_13:to_13, isbn_13:to_10, isbn_13:prefix, isbn_13:check_digit, isbn_13:check_digit_expected
check digit
issn
Serial publication number (ISSN)
NNNN-NNNC: 7 digits and a check character (0–9 or X).
Example: 0378-5955
GET parts: issn:check_digit, issn:check_digit_expected
check digit
ean_13
EAN-13 barcode
13 digits with a GS1 check digit.
Example: 4006381333931
GET parts: ean_13:gs1_prefix_country, ean_13:gtin14, ean_13:check_digit, ean_13:check_digit_expected
check digit
ean_8
EAN-8 barcode
8 digits with a GS1 check digit.
Example: 73513537
GET parts: ean_8:gs1_prefix_country, ean_8:gtin14, ean_8:check_digit, ean_8:check_digit_expected
check digit
gtin
GTIN (any length)
8, 12, 13 or 14 digits with a GS1 check digit.
Example: 00012345600012
GET parts: gtin:gs1_prefix_country, gtin:gtin14, gtin:check_digit, gtin:check_digit_expected
check digit
sscc
Shipping label code (SSCC)
18 digits with a GS1 check digit.
Example: 106141411234567897
GET parts: sscc:check_digit, sscc:check_digit_expected
check digit
gln
GS1 location number (GLN)
13 digits with a GS1 check digit.
Example: 4006381333931
GET parts: gln:check_digit, gln:check_digit_expected
check digit

Banking

International bank accounts and bank codes.

CodeWhat it checksVerified by
iban
International bank account (IBAN)
2-letter country, 2 check digits, then the national account (BBAN); spaces allowed. The length must match the country's (SWIFT IBAN registry) and the ISO 7064 mod 97 check must pass.
Example: GB82 WEST 1234 5698 7654 32
GET parts: iban:country, iban:formatted, iban:bban, iban:check_digits, iban:check_digit, iban:check_digit_expected
check digit
swift_bic
Bank SWIFT/BIC code
8 or 11 characters: 4 for the bank, a 2-letter country, 2 for the location, an optional 3-character branch (XXX = head office). Format only.
Example: DEUTDEFF500
GET parts: swift_bic:bank, swift_bic:country, swift_bic:location, swift_bic:branch, swift_bic:is_test
format only

Securities & companies

Stock and bond identifiers, and the global company identifier.

CodeWhat it checksVerified by
cusip
Security ID, US (CUSIP)
9 characters: 8 letters, digits or * @ # and a check digit.
Example: 037833100
GET parts: cusip:check_digit, cusip:check_digit_expected
check digit
isin
Security ID, international (ISIN)
12 characters: a 2-letter country, 9 letters or digits, and a Luhn check digit.
Example: US0378331005
GET parts: isin:country, isin:nsin, isin:check_digit, isin:check_digit_expected
check digit
sedol
Security ID, UK (SEDOL)
7 characters: 6 digits or consonants and a check digit.
Example: 0263494
GET parts: sedol:check_digit, sedol:check_digit_expected
check digit
lei
Legal Entity Identifier (LEI)
20 letters and digits ending in 2 check digits (ISO 17442, mod 97).
Example: 5493001KJTIIGC8Y1R12
GET parts: lei:check_digit, lei:check_digit_expected
check digit

Healthcare (US)

Provider and prescriber numbers.

CodeWhat it checksVerified by
npi
Provider ID (NPI)
10 digits starting with 1 or 2, with the CMS Luhn check digit (prefix 80840).
Example: 1234567893
GET parts: npi:check_digit, npi:check_digit_expected
check digit
dea
DEA registration number
2 letters (a registrant type, then a surname initial or 9) and 7 digits, the last a check digit.
Example: AB1234563
GET parts: dea:check_digit, dea:check_digit_expected
check digit

Devices & logistics

Phone hardware, SIM cards and shipping containers.

CodeWhat it checksVerified by
imei
Phone hardware ID (IMEI)
15 digits with a Luhn check digit.
Example: 490154203237518
GET parts: imei:tac, imei:serial, imei:check_digit, imei:check_digit_expected
check digit
iccid
SIM card number (ICCID)
18–22 digits starting 89, with a Luhn check digit.
Example: 8901260222780000002
GET parts: iccid:check_digit, iccid:check_digit_expected
check digit
container
Shipping container number (ISO 6346)
3-letter owner, category U, J or Z, 6-digit serial, check digit: CSQU 305438 3.
Example: CSQU 305438 3
GET parts: container:owner, container:category, container:serial, container:check_digit, container:check_digit_expected
check digit

International IDs

National identifiers from outside the US. Each code starts with its country.

CodeWhat it checksVerified by
ca_sin
Canada Social Insurance Number
9 digits (spaces or dashes allowed), not starting with 0 or 8, with a Luhn check digit.
Example: 130 692 544
GET parts: ca_sin:check_digit, ca_sin:check_digit_expected
check digit
ca_postal
Canada postal code
A1A 1A1 with or without the space — the same test a CA Postal Code column uses. Format only.
Example: K1A 0B1
GET parts: ca_postal:rural
format only
uk_nino
UK National Insurance number
2 letters, 6 digits and a letter A–D (QQ 12 34 56 C). Letters D F I Q U V never appear, O never second, and some prefixes are never issued. Format only.
Example: AB 12 34 56 C
format only
br_cpf
Brazil CPF
11 digits (111.444.777-35), two mod 11 check digits; all-same-digit numbers are rejected.
Example: 111.444.777-35
GET parts: br_cpf:check_digit, br_cpf:check_digit_expected
check digit
br_cnpj
Brazil CNPJ
14 digits (11.222.333/0001-81), two mod 11 check digits.
Example: 11.222.333/0001-81
GET parts: br_cnpj:check_digit, br_cnpj:check_digit_expected
check digit
es_dni
Spain DNI
8 digits and a control letter (12345678Z).
Example: 12345678Z
GET parts: es_dni:check_digit, es_dni:check_digit_expected
check digit
es_nie
Spain NIE
X, Y or Z, 7 digits and a control letter (X1234567L).
Example: X1234567L
GET parts: es_nie:check_digit, es_nie:check_digit_expected
check digit
cn_resident_id
China Resident ID
18 characters: 17 digits including a birth date, and an ISO 7064 mod 11-2 check character (0–9 or X).
Example: 11010519491231002X
GET parts: cn_resident_id:check_digit, cn_resident_id:check_digit_expected
check digit
in_aadhaar
India Aadhaar
12 digits (spaces allowed) not starting with 0 or 1, with a Verhoeff check digit.
Example: 2341 2341 2346
GET parts: in_aadhaar:check_digit, in_aadhaar:check_digit_expected
check digit

Check-digit algorithms

The bare arithmetic, for a number you know uses a scheme but that has no code of its own. Each checks only that the last digit(s) match.

CodeWhat it checksVerified by
luhn
Luhn check digit (any length)
Any run of digits whose last digit is its Luhn check digit.
Example: 79927398713
GET parts: luhn:check_digit, luhn:check_digit_expected
check digit
gtin_mod10
GS1 mod 10 check digit (any length)
Any run of digits whose last digit is its GS1 (3/1 weighted) check digit.
Example: 036000291452
GET parts: gtin_mod10:check_digit, gtin_mod10:check_digit_expected
check digit
mod97
ISO 7064 mod 97 (any length)
Letters and digits (A=10 … Z=35) whose value mod 97 is 1: the IBAN / LEI scheme, check digits last.
Example: 5493001KJTIIGC8Y1R12
GET parts: mod97:check_digit, mod97:check_digit_expected
check digit
verhoeff
Verhoeff check digit (any length)
Any run of digits whose last digit is its Verhoeff check digit.
Example: 2363
GET parts: verhoeff:check_digit, verhoeff:check_digit_expected
check digit
damm
Damm check digit (any length)
Any run of digits whose last digit is its Damm check digit.
Example: 5724
GET parts: damm:check_digit, damm:check_digit_expected
check digit

Lookup tables

A few parts come from small tables built into Summer. These cover the common cases, not every one in the world:

IBAN country lengths, EIN prefixes, routing-number ranges and SSN areas are complete.

← All functions