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:
VALIDATE(value, code) asks is this a well-formed card number / VIN / IBAN?GET(value, "code:part") reads a part out of one: a VIN's model year, an IBAN's
country, a card's last four digits.Jump to the list of codes.
VALIDATE({VIN}, "vin")
VALIDATE({Card Number}, "credit_card", "bool")
The third argument is optional and chooses what an invalid value gives:
| Value | Default ("error") | With "bool" |
|---|---|---|
| Blank | blank | blank |
| Valid | true | true |
| Invalid | an error saying why | false |
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:
VIN: expected 17 characters, found 16: wrong lengthVIN: contains O, which VINs never use (no I, O or Q): a character the format never usesSSN: area 000 is never issued: a structure ruleIBAN: unknown country code ZZ, IBAN: GB IBANs are 22 characters, found 21Credit card: check digit is 2, expected 1: the check digit doesn't matchA misspelled code, like VALIDATE(x, "vinn"), is an error on every row, so it
can't pass unnoticed.
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.
4111 1111 1111 1111, GB82 WEST 1234 5698 7654 32,
978-0-306-40615-7, 111.444.777-35. Upper or lower case.ISBN 0-306-40615-2, ISSN 0378-5955,
and for cards a brand: Visa 4111 1111 1111 1111. A brand must match the number;
Visa 5555 5555 5555 4444 fails, because 5555 is a Mastercard prefix.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:
****-****-****-1234, XXXX XXXX XXXX 1234, ************1234, •••• •••• •••• 1234****1234, •••• 1234, ...1234, x1234411111******1111ending in 1234, Amex ending 1005, Visa ****1234, MC x1234, VISA-1234, 1234 (Visa)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.
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:
isbn:to_10 is blank for them.USA, DEU), the same as
Summer's other country parts, so the column can show country names.vin:model_year repeats every 30 years. Summer uses the North American rule:
a digit in position 7 means 1980–2009, a letter means 2010–2039.gtin:gs1_prefix_country is where the company registered its barcodes, not
where the product was made.ca_postal:rural is true when the second character is 0, Canada Post's mark
for a rural area; 1–9 is urban.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.
Every code verified by a check digit has two more parts:
code:check_digit: the check digit the value carries.code:check_digit_expected: the check digit it should carry. You can give the
full value (its own check digit is ignored) or just the digits before it.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.
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"
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.
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 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.
The identifiers most US data holds: payment cards, tax numbers, bank routing, phones, email, vehicles, barcodes, books and UUIDs.
| Code | What it checks | Verified by |
|---|---|---|
credit_cardCredit 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 1111GET 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_maskedCredit 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 ****1234GET parts: credit_card_masked:brand, credit_card_masked:last4, credit_card_masked:masked, credit_card_masked:iin | format only |
ssnSocial 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-1120GET parts: ssn:state_guess, ssn:masked, ssn:area, ssn:group, ssn:serial | format only |
einEmployer ID / EIN (US) | 12-3456789 or 123456789, with a prefix the IRS assigns. Format only. Example: 12-3456789 | format only |
routing_numberBank 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: 011000015GET parts: routing_number:fed_district, routing_number:check_digit, routing_number:check_digit_expected | check digit |
phonePhone 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_usPhone, 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_e164Phone, 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 |
emailEmail address | [email protected] — the same test an Email column uses. A practical check, not full RFC 5322. Format only. Example: [email protected] | format only |
zipZIP code (US) | 12345 or ZIP+4 12345-6789 — the same test a ZIP Code column uses. Format only. Example: 37203-1234 | format only |
vinVehicle 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: 1M8GDM9AXKP042788GET 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_structureVehicle 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: WVWZZZ1JZXW000001GET 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 |
upcUPC barcode | 12 digits with a GS1 check digit. Spaces and dashes allowed. Example: 036000291452GET parts: upc:gs1_prefix_country, upc:gtin14, upc:check_digit, upc:check_digit_expected | check digit |
isbnBook 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-7GET parts: isbn:to_13, isbn:to_10, isbn:prefix, isbn:check_digit, isbn:check_digit_expected | check digit |
uuidUUID / 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 |
GS1 barcodes in every length, and the book and serial numbers.
| Code | What it checks | Verified by |
|---|---|---|
isbn_10ISBN-10 | 9 digits and a check character (0–9 or X), hyphens allowed. Example: 0-306-40615-2GET parts: isbn_10:to_13, isbn_10:to_10, isbn_10:prefix, isbn_10:check_digit, isbn_10:check_digit_expected | check digit |
isbn_13ISBN-13 | 13 digits starting 978 or 979, hyphens allowed, GS1 check digit. Example: 978-0-306-40615-7GET parts: isbn_13:to_13, isbn_13:to_10, isbn_13:prefix, isbn_13:check_digit, isbn_13:check_digit_expected | check digit |
issnSerial publication number (ISSN) | NNNN-NNNC: 7 digits and a check character (0–9 or X). Example: 0378-5955GET parts: issn:check_digit, issn:check_digit_expected | check digit |
ean_13EAN-13 barcode | 13 digits with a GS1 check digit. Example: 4006381333931GET parts: ean_13:gs1_prefix_country, ean_13:gtin14, ean_13:check_digit, ean_13:check_digit_expected | check digit |
ean_8EAN-8 barcode | 8 digits with a GS1 check digit. Example: 73513537GET parts: ean_8:gs1_prefix_country, ean_8:gtin14, ean_8:check_digit, ean_8:check_digit_expected | check digit |
gtinGTIN (any length) | 8, 12, 13 or 14 digits with a GS1 check digit. Example: 00012345600012GET parts: gtin:gs1_prefix_country, gtin:gtin14, gtin:check_digit, gtin:check_digit_expected | check digit |
ssccShipping label code (SSCC) | 18 digits with a GS1 check digit. Example: 106141411234567897GET parts: sscc:check_digit, sscc:check_digit_expected | check digit |
glnGS1 location number (GLN) | 13 digits with a GS1 check digit. Example: 4006381333931GET parts: gln:check_digit, gln:check_digit_expected | check digit |
International bank accounts and bank codes.
| Code | What it checks | Verified by |
|---|---|---|
ibanInternational 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 32GET parts: iban:country, iban:formatted, iban:bban, iban:check_digits, iban:check_digit, iban:check_digit_expected | check digit |
swift_bicBank 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: DEUTDEFF500GET parts: swift_bic:bank, swift_bic:country, swift_bic:location, swift_bic:branch, swift_bic:is_test | format only |
Stock and bond identifiers, and the global company identifier.
| Code | What it checks | Verified by |
|---|---|---|
cusipSecurity ID, US (CUSIP) | 9 characters: 8 letters, digits or * @ # and a check digit. Example: 037833100GET parts: cusip:check_digit, cusip:check_digit_expected | check digit |
isinSecurity ID, international (ISIN) | 12 characters: a 2-letter country, 9 letters or digits, and a Luhn check digit. Example: US0378331005GET parts: isin:country, isin:nsin, isin:check_digit, isin:check_digit_expected | check digit |
sedolSecurity ID, UK (SEDOL) | 7 characters: 6 digits or consonants and a check digit. Example: 0263494GET parts: sedol:check_digit, sedol:check_digit_expected | check digit |
leiLegal Entity Identifier (LEI) | 20 letters and digits ending in 2 check digits (ISO 17442, mod 97). Example: 5493001KJTIIGC8Y1R12GET parts: lei:check_digit, lei:check_digit_expected | check digit |
Provider and prescriber numbers.
| Code | What it checks | Verified by |
|---|---|---|
npiProvider ID (NPI) | 10 digits starting with 1 or 2, with the CMS Luhn check digit (prefix 80840). Example: 1234567893GET parts: npi:check_digit, npi:check_digit_expected | check digit |
deaDEA registration number | 2 letters (a registrant type, then a surname initial or 9) and 7 digits, the last a check digit. Example: AB1234563GET parts: dea:check_digit, dea:check_digit_expected | check digit |
Phone hardware, SIM cards and shipping containers.
| Code | What it checks | Verified by |
|---|---|---|
imeiPhone hardware ID (IMEI) | 15 digits with a Luhn check digit. Example: 490154203237518GET parts: imei:tac, imei:serial, imei:check_digit, imei:check_digit_expected | check digit |
iccidSIM card number (ICCID) | 18–22 digits starting 89, with a Luhn check digit. Example: 8901260222780000002GET parts: iccid:check_digit, iccid:check_digit_expected | check digit |
containerShipping container number (ISO 6346) | 3-letter owner, category U, J or Z, 6-digit serial, check digit: CSQU 305438 3. Example: CSQU 305438 3GET parts: container:owner, container:category, container:serial, container:check_digit, container:check_digit_expected | check digit |
National identifiers from outside the US. Each code starts with its country.
| Code | What it checks | Verified by |
|---|---|---|
ca_sinCanada Social Insurance Number | 9 digits (spaces or dashes allowed), not starting with 0 or 8, with a Luhn check digit. Example: 130 692 544GET parts: ca_sin:check_digit, ca_sin:check_digit_expected | check digit |
ca_postalCanada postal code | A1A 1A1 with or without the space — the same test a CA Postal Code column uses. Format only. Example: K1A 0B1GET parts: ca_postal:rural | format only |
uk_ninoUK 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_cpfBrazil CPF | 11 digits (111.444.777-35), two mod 11 check digits; all-same-digit numbers are rejected. Example: 111.444.777-35GET parts: br_cpf:check_digit, br_cpf:check_digit_expected | check digit |
br_cnpjBrazil CNPJ | 14 digits (11.222.333/0001-81), two mod 11 check digits. Example: 11.222.333/0001-81GET parts: br_cnpj:check_digit, br_cnpj:check_digit_expected | check digit |
es_dniSpain DNI | 8 digits and a control letter (12345678Z). Example: 12345678ZGET parts: es_dni:check_digit, es_dni:check_digit_expected | check digit |
es_nieSpain NIE | X, Y or Z, 7 digits and a control letter (X1234567L). Example: X1234567LGET parts: es_nie:check_digit, es_nie:check_digit_expected | check digit |
cn_resident_idChina Resident ID | 18 characters: 17 digits including a birth date, and an ISO 7064 mod 11-2 check character (0–9 or X). Example: 11010519491231002XGET parts: cn_resident_id:check_digit, cn_resident_id:check_digit_expected | check digit |
in_aadhaarIndia Aadhaar | 12 digits (spaces allowed) not starting with 0 or 1, with a Verhoeff check digit. Example: 2341 2341 2346GET parts: in_aadhaar:check_digit, in_aadhaar:check_digit_expected | check digit |
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.
| Code | What it checks | Verified by |
|---|---|---|
luhnLuhn check digit (any length) | Any run of digits whose last digit is its Luhn check digit. Example: 79927398713GET parts: luhn:check_digit, luhn:check_digit_expected | check digit |
gtin_mod10GS1 mod 10 check digit (any length) | Any run of digits whose last digit is its GS1 (3/1 weighted) check digit. Example: 036000291452GET parts: gtin_mod10:check_digit, gtin_mod10:check_digit_expected | check digit |
mod97ISO 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: 5493001KJTIIGC8Y1R12GET parts: mod97:check_digit, mod97:check_digit_expected | check digit |
verhoeffVerhoeff check digit (any length) | Any run of digits whose last digit is its Verhoeff check digit. Example: 2363GET parts: verhoeff:check_digit, verhoeff:check_digit_expected | check digit |
dammDamm check digit (any length) | Any run of digits whose last digit is its Damm check digit. Example: 5724GET parts: damm:check_digit, damm:check_digit_expected | check digit |
A few parts come from small tables built into Summer. These cover the common cases, not every one in the world:
vin:manufacturer: about 90 major manufacturer codes. Others give blank.vin:country: the main producing countries.gtin:gs1_prefix_country: the most common GS1 prefixes, plus the special
ranges (books, coupons, restricted).credit_card.IBAN country lengths, EIN prefixes, routing-number ranges and SSN areas are complete.