validatorjs / validator.js

String validation
MIT License
23.01k stars 2.29k forks source link

regex for country code PT #2195

Open zeworks opened 1 year ago

zeworks commented 1 year ago

https://github.com/validatorjs/validator.js/blob/43803c08d23b9cf316f2e804445b643b52920121/src/lib/isPassportNumber.js#L59

the regex, should be /^[A-Z]{1,2}\d{6}$/ because there's some passports that have at the beginning two letters and others, a single letter. Ex:

pano9000 commented 1 year ago

Hi @zeworks,

thanks for reporting this. some reference for this, that seems to be confirming this: https://www.santander.de/content/pdf/informationen/nationale_identifikationsmerkmale.pdf check page 5

The passport of uniform and optical model issued before April 2018 consists of a
notebook with 32 pages numbered, identified by one letter and six digits:
Position 1: letter [A-Z] and Position 2 - 6: digits [0-9].

The passport of uniform and optical model issued after April 2018 consists of a
notebook with 32 (requested by normal travel) or 48 (requested by a frequent travel)
pages numbered, identified by two letters and six digits:
Position 1-2: letter [A-Z] and Position 3 - 8: digits [0-9].
pano9000 commented 1 year ago

do you maybe happen to have a Portuguese official source for these numbers too? because something is off here, either in the reference I provided above, or in the current validators RegExp