This package is intended to provide validators for various Polish identification numbers together with an option for generating random correct number.
Currently only the PESEL number is supported.
The package offers the following functions:
- validatePESEL,
- getBirthDatefromPESEL,
- generateRandomPESEL.
This function offers an extended validation of the PESEL number.
The following checks are performed in order:
- whether the argument is in the correct format,
- whether the birth date specified in the number has already passed,
- whether the birth month is valid,
- whether the birth month contained the day of birth (to exclude days such as February 30th),
- whether the check digit is valid.
The functions accepts only string arguments with 11 digit characters. PESEL numbers for people born after 1899 and up to the current year are supported.
Number argument are not supported as the PESEL number may contain leading zeroes.
The function returns a boolean value indicating whether the provieded nunber is valid.
This function extracts the birth date from a PESEL number. The number is validated first using the validatePESEL and supplying invalid number will result in an error.
The functions accepts only string arguments with 11 digit characters. PESEL numbers for people born after 1899 and up to the current year are supported.
Number argument are not supported as the PESEL number may contain leading zeroes.
The function returns JavaScript Date object with the extracted date.
The function generates a random, valid PESEL number
Currently the function does not accept any arguments. Customisation options are planned.
The function return a string containing a PESEL number for a person of random sex born between 1900 and the current year.