Skip to Content
Onshore is in early access. Don’t load real customer data until the items in Known limits are closed.

Check rules

A check rule (validator) is a test a pattern’s match must pass, such as an ID’s check digit. You choose from a fixed menu; nobody can supply their own code, which keeps the engine safe. Use them in your own data types and country packs.

Soft and definitive

  • Soft rules add confidence when they pass (0.6 becomes 0.9). When they fail, the match keeps 0.6, so words nearby can still lift it over the threshold.
  • Definitive rules rule a match out when they fail, whatever words are nearby. A wrong check letter means it isn’t that ID.

The menu

RuleKindWhat it checksSettings
Exact lengthSoftThe match has exactly this many charactersLength
Prefix listSoftIt starts with one of thesePrefixes
LuhnSoftThe Luhn check used by card numbers and many IDs—
Mod 11SoftWeights 2 to 7 repeating from the right; the last digit is 11 minus the remainder—
Custom checksumSoftDigits times your weights; the check digit at a position is the modulus minus the remainderWeights, modulus, check position
Mod 11 with your weightsDefinitiveDigits times your weights. The check is 11 minus the remainder (most schemes) or the remainder itself. 10 is written X, 11 is 0Weights, which form, check position
Mod 97DefinitiveISO 7064 mod 97-10, as IBANs use: move characters from the start to the end, turn letters into numbers (A=10 … Z=35), and the whole must leave 1Characters to move (4 for an IBAN)
Check letterDefinitiveDigits times weights, plus a number, modulo the alphabet’s length, picks the letter at a positionWeights, letters in order, number added, letter position
A real date inside the numberDefinitiveDigits from a position hold a real calendar dateLayout (YYMMDD, YYYYMMDD, DDMMYY, DDMMYYYY, MMDDYY), start position counting digits only

Spaces, dashes and dots are ignored. Positions count from 1; 0 or -1 means the last character.

Worked examples

Spain’s DNI (12345678Z): 8 digits and a letter, the number modulo 23 picking from TRWAGMYFPDXBNJZSQVHLCKE. As a check letter rule: letters TRWAGMYFPDXBNJZSQVHLCKE, weights 14,6,19,18,11,8,10,1 (powers of 10 modulo 23), number added 0, letter position 0.

Singapore’s NRIC (S1234567D): weights 2,7,6,5,4,3,2 over the 7 digits, letters JZIHGFEDCBA, position 0.

An IBAN: mod 97, characters to move 4.

An ISBN-10 (0-306-40615-2, or ending X): mod 11 with weights 10,9,8,7,6,5,4,3,2, form “11 minus the remainder”.

A birth date inside an ID (8001015009087): date layout YYMMDD from digit 1. Two-digit years are checked against 2000+, so 29 February 2000 passes and 29 February 2001 doesn’t.

Test each rule with made-up examples that must match and must not match. The pack and data type builders run them for you.

Last updated on