PHPackages                             michalsroczynski/pesel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. michalsroczynski/pesel

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

michalsroczynski/pesel
======================

Walidacja numeru PESEL. Oprócz oficjalnej walidacji, sprawdza długość i poprawność wszystkich znaków w numerze PESEL, oraz datę urodzenia - czy nie jest z przyszłości.

1.0.0(7y ago)144MITPHPPHP &gt;=7.2

Since Feb 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/michalsroczynski/pesel)[ Packagist](https://packagist.org/packages/michalsroczynski/pesel)[ RSS](/packages/michalsroczynski-pesel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Walidacja numeru PESEL / PESEL Validation
=========================================

[](#walidacja-numeru-pesel--pesel-validation)

[![](https://camo.githubusercontent.com/33aae1925992deb86151b56fea8dcfaf05a52a5265a422864075edfce93c4309/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/33aae1925992deb86151b56fea8dcfaf05a52a5265a422864075edfce93c4309/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d666c6174)[![](https://camo.githubusercontent.com/500c880faf877dd090a1fb3c61048bdaff722588be2d99d69c6c03a20bca8590/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d706c6173746963)](https://camo.githubusercontent.com/500c880faf877dd090a1fb3c61048bdaff722588be2d99d69c6c03a20bca8590/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d706c6173746963)[![](https://camo.githubusercontent.com/e6ca73be3eec277a43c54d87e2f1432edde8331fd01185f6be8c8e8d8a19df42/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d706c6173746963)](https://camo.githubusercontent.com/e6ca73be3eec277a43c54d87e2f1432edde8331fd01185f6be8c8e8d8a19df42/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d696368616c73726f637a796e736b692f706573656c2e7376673f7374796c653d706c6173746963)[![](https://camo.githubusercontent.com/1b22ba64207c70658e047649f6930926b077e74c30e2442d71231daf3f90d5b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6d696368616c73726f637a796e736b692f706573656c2f746f74616c2e7376673f7374796c653d706c6173746963)](https://camo.githubusercontent.com/1b22ba64207c70658e047649f6930926b077e74c30e2442d71231daf3f90d5b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f6d696368616c73726f637a796e736b692f706573656c2f746f74616c2e7376673f7374796c653d706c6173746963)[![](https://camo.githubusercontent.com/b3fe854f0fdc50d99425962ad42ba24313ea35e6f0bdb6f71b1e97df3ab60181/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696368616c73726f637a796e736b692f706573656c2e7376673f6c6162656c3d7061636b6167697374253230646f776e6c6f616473267374796c653d706c6173746963)](https://camo.githubusercontent.com/b3fe854f0fdc50d99425962ad42ba24313ea35e6f0bdb6f71b1e97df3ab60181/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d696368616c73726f637a796e736b692f706573656c2e7376673f6c6162656c3d7061636b6167697374253230646f776e6c6f616473267374796c653d706c6173746963)

Obiekt klasy waliduje numer PESEL używając oficjalnej walidacji opartej na wagach. Metoda `validate()` przed rozpoczęciem walidacji sprawdza poprawność znaków w numerze: czy jest ich 11 i czy nie zawierają innych znaków niż cyfry. Ponadto sprawdzane jest czy data w numerze PESEL nie jest z przyszłości. Umożliwia to sprawdzenie czy ktoś nie podał wygenerowanego numeru. Funkcja zwraca tablicę zawierającą m.in.: wiek, płeć, czy osoba jest pełnoletnia i ewentualne błędy w numerze. Metoda `getBirthDate()` zwraca datę urodzenia w czasie unixowym.

---

Class' object validate PESEL number by using official validation method based on weights. Method `validate()` before it starts validation, checks if all characters are correct: if there are 11 characters and only digits. More over it checks if birth date is not from future. Because of this you can be sure if someone didn't provide some generated PESEL number. Function returns an array with: age, sex, information about being adult, and errors if there are any. Method `getBirthDate()` return birth date in unix time stamp.

Usage
-----

[](#usage)

**Create object:**

```
$peselNumber = '12345678901';
$pesel = new Pesel($peselNumber);
```

**Validate:**

```
$pesel->validate()
```

result:

```
array (
  'valid' => true,
  'sex' => 'Male',
  'isAdult' => true,
  'age' => '49',
  'birthDate' =>
  array (
    'year' => '1970',
    'month' => '01',
    'day' => '01',
  ),
  'error' => false,
  'errorMessage' => NULL,
)
```

**Get birth date as timestamp:**

```
$pesel->getBirthDate()
```

result:

```
1546300800

```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2641d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/570643a40f40d8e34144a924cfbb4b132e078d72f9f3e6b0d18db24cc90df2b4?d=identicon)[michalsroczynski](/maintainers/michalsroczynski)

---

Top Contributors

[![michalsroczynski](https://avatars.githubusercontent.com/u/18038531?v=4)](https://github.com/michalsroczynski "michalsroczynski (26 commits)")

### Embed Badge

![Health badge](/badges/michalsroczynski-pesel/health.svg)

```
[![Health](https://phpackages.com/badges/michalsroczynski-pesel/health.svg)](https://phpackages.com/packages/michalsroczynski-pesel)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
