This project is not covered by Drupal’s security advisory policy.
International Personal Documentation Validator (IPD Validator)
The IPD Validator module provides an extensible, service-based API to validate personal identification documents (like DNI, CUIT, CUIL, etc.) for different countries.
It is designed for backend use only — there is no user interface.
🔍 Why use this module?
- ✅ Need to validate national ID numbers during profile registration or form submissions?
- ✅ Want to enforce country-specific document formatting and structure?
- ✅ Looking for an easily extensible plugin-based API for validators?
If you answered yes to any of the above, IPD Validator is for you.
💡 Use cases
- Form validation for user registration, profile update, or custom forms.
- Validation before syncing data to external CRMs or APIs that require valid ID numbers.
- Backend sanitization of personal ID inputs semantically tied to country-specific rules.
🔌 How it works
The module uses the Drupal Plugin API to provide document validators, each responsible for one country's logic. A validator plugin includes a country_code, label, description, and logic for isValid() and optional format().
The core service plugin.manager.ipd_validator exposes methods to:
validate($document, $countryCode)format($document, $countryCode)getSupportedCountries()
If no validator exists for a given country code, the document is considered valid by default.
🚫 No front-end interface
This module provides no block, form element, or end-user interface — it is intended for developers and is used programmatically.
🔧 Example
// Using the Validator service. $validator = \Drupal::service('plugin.manager.ipd_validator'); // Validate a CUIT (Argentina). $is_valid = $validator->validate('20304050607', 'AR');
🧪 Built-in validators
Currently includes support for:
- AR – Argentina (DNI / CUIT / CUIL)
- BD – Bangladesh (NID)
- BO – Bolivia (Cédula de Identidad)
- BR – Brazil (CPF / CNPJ)
- CI – Côte d'Ivoire (CNI)
- CL – Chile (CI / RUT)
- CM – Cameroon (CNI)
- CN – China (Resident Identity Card)
- CO – Colombia (Cédula de Ciudadanía)
- CR – Costa Rica (Cédula de Identidad)
- EC – Ecuador (Cédula de Identidad)
- EG – Egypt (National ID)
- GH – Ghana (Ghana Card)
- GT – Guatemala (CUI)
- HN – Honduras (DNI)
- ID – Indonesia (NIK)
- IN – India (PAN)
- JO – Jordan (National ID Number)
- JP – Japan (My Number)
- KE – Kenya (National ID)
- MA – Morocco (CNIE)
- MX – Mexico (CURP)
- MY – Malaysia (NRIC)
- NE – Niger (CNI)
- NG – Nigeria (NIN)
- NI – Nicaragua (DNI)
- PA – Panama (Cédula)
- PE – Peru (DNI)
- PH – Philippines (PSN)
- PK – Pakistan (CNIC)
- PY – Paraguay (CI)
- RW – Rwanda (National ID)
- SA – Saudi Arabia (National ID)
- SN – Senegal (CNI)
- SV – El Salvador (DUI)
- TH – Thailand (Personal ID)
- TR – Turkey (T.C. Kimlik No)
- TZ – Tanzania (National ID)
- UG – Uganda (NIC)
- UY – Uruguay (CI / RUT)
- VN – Vietnam (VNID)
- ZA – South Africa (ID Number)
- ZM – Zambia (NRC)
Each validator encapsulates validation rules specific to the document structure and format required by the target country.
New validators can be added by implementing a simple plugin in your own module.
You can extend it easily by writing your own plugin via the @Validator annotation in a custom module.
🧪 Tests
Includes both Unit and Kernel tests to ensure plugin stability and correct API behavior.
🚀 Future plans
- Additional validators for more countries (Spain, Mexico, etc.).
- Optional integration with form validation via hook or plugin manager wrapper.
- Configurable response handling (log invalid documents, etc.).
👤 Maintainer
Module created and maintained by Pedro Peláez (PSF_).
🤝 Contributions and patches welcome!
Feel free to create issues or merge requests with new validator plugins or ideas to improve the module.
Project information
Seeking co-maintainer(s)
Maintainers are looking for help reviewing issues.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Automation, Developer tools, Integrations
- Created by psf_ on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
