Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module provides a backend API for validating personal identification documents from various countries, using a plugin system for easy extensibility. It helps ensure that national ID formats and structures are correct during form submissions or data synchronization.

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.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
May 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0 Stable 10–11 May 14, 2025
1.0.x-dev Dev 10–11 May 14, 2025