feat(isPassportNumber): fix regex for CN by anirudhgiri · Pull Request #1714 · validatorjs/validator.js
Fixes #1686
The format for passport numbers for CN passports are as follows:
- Starts with either a "G" (for Ordinary) or an "E" (for Electronic)
- If it starts with "G", 8 numbers follow
- If it starts with "E" either 8 numbers follow, or a letter [A-Z] (except "I" or "O") and 7 numbers follow
Valid Examples:
- G12345678
- E12345678
- EA1234567
So the above conditions were implemented with the following regex : ^G\d{8}$|^E(?![IO])[A-Z0-9]\d{7}$
The appropriate testes were added to validators.js with all of them passing.
Checklist
- PR contains only changes related; no stray files, etc.
- README updated (where applicable)
- Tests written (where applicable)