PESEL

The Polish national identification number carries a person’s birth date and gender. A PESEL the program makes always agrees with both.

What a PESEL is

Eleven digits: the birth date as year, month and day, four serial digits, and a check digit. The century is hidden in the month: 1 to 12 for the 1900s, 21 to 32 for the 2000s, 41 to 52 for the 2100s, 61 to 72 for the 2200s and 81 to 92 for the 1800s. The last serial digit gives the gender: even for a woman, odd for a man.

The check digit

Multiply the first ten digits by 1, 3, 7, 9, 1, 3, 7, 9, 1, 3 and add up the products. Take the last digit of the total and subtract it from 10. The result is the check digit, and when the total ends in 0 the check digit is 0.

Valid PESEL numbers for your tests

terminal
$ qadg quick pesel --count 5 --gender female --birth-date 1990-04-12 --seed example
90041247762
90041225382
90041249887
90041275981
90041285083

--gender and --birth-date fix what the number carries, and without them each number gets its own. In a recipe, the rule pesel matches: [birth_date, gender] makes every PESEL agree with the two columns beside it. The scheme covers the years 1800 to 2299 only. No block of PESEL numbers is set aside for testing, so a generated one can belong to a real person: keep it in test systems.

What your application should do with a broken one

Refuse a PESEL whose check digit does not match. A few swaps of two neighbouring digits leave the check digit right, so the program does not count such a swap as damage and says so in the manifest.

Then the harder case: a PESEL that is correct on its own and carries a different birth date or gender than the form beside it. Each value passes every check on its own and only the pair is wrong, so only a form that compares the PESEL with the birth date and the gender will catch it. The manifest marks this answer as depending on your application, because not every form asks for a birth date and a gender.

Broken ones for your tests

The recipe below makes 100 values and asks for damage in 20% of the rows. Download it and run it as it is, then change the count or the share to fit your tests.

The recipe

pesel.yaml
# PESEL numbers for testing, with one broken value asked for in about a fifth
# of the rows.
#
# Every PESEL agrees with the birth date and the gender beside it. A PESEL can
# belong to a real person, so keep the file in test systems. The damage breaks
# the check digit, or leaves a correct PESEL that disagrees with the birth date
# or the gender, and the manifest says your application should reject each one.
# It also lists the damage this build could not carry out, with the reason.
#
#   qadg generate pesel.yaml
#
# writes person.csv, expectation-manifest.json and run-note.json. The same seed
# breaks the same values on every machine.
version: "0.1"
seed: "pesel"
locale: pl-PL
entities:
  person:
    count: 100
    fields:
      gender:     { generator: gender }
      birth_date: { generator: birth_date }
      pesel:      { generator: pesel }
    consistency:
      - pesel matches: [birth_date, gender]
policy:
  layers: [L3, L4]
  rows: 20%
  per_row: exactly_one
output:
  format: csv

Run it

Save the recipe, then run this in the same folder. This is what the program printed for it.

terminal
$ qadg generate pesel.yaml
       person: 100 rows, 3 columns
1 table, 100 rows written
23 defects ordered, 5 applied, manifest in expectation-manifest.json
18 defects could not be applied, and the manifest carries the reason for each one
  2 because this run lacks something they need, and the manifest says what for each one
  16 because this build has no implementation of them yet

What it damaged

The recipe ordered 23 defects, and this build applied the 5 below. The other 18 are in the manifest as not applied, each with its reason, and the run above counts them by reason.

L3.checksum.off_by_onereject

person 45, column pesel

92091396151 → 92091396152

L3.checksum.transposed_digitsreject

person 50, column pesel

49040402768 → 49040420768

L4.coherence.national_id_vs_birthdate~ reject

person 52, column pesel

35030209411 → 40030209415

L4.coherence.national_id_vs_gender~ reject

person 57, column pesel

53041506840 → 53041506857

L3.checksum.off_by_onereject

person 87, column pesel

54092512734 → 54092512735

Sources

  • gov.pl, Czym jest numer PESEL, read on 2 August 2026.
  • Ministry of Finance of Poland, POLAND - Information on Tax Identification Numbers, on the European Commission’s TIN portal, which works the check digit through.