In the realm of software testing and quality assurance, generating realistic and valid identification numbers is crucial for ensuring application integrity. The es_dni function within the mock-jutsu library provides developers with a seamless way to generate authentic Spanish Documento Nacional de Identidad (DNI) strings. This specific type of mock data is essential for any platform targeting users in Spain, as it adheres strictly to the official Spanish regulatory standards for personal identification, ensuring that your test environment mirrors real-world conditions as closely as possible.
The technical implementation of the es_dni generator follows the standard MOD-23 algorithm used by the Spanish Ministry of the Interior. Each generated value consists of an eight-digit sequence followed by a control letter, which is calculated based on the remainder of the numerical part divided by 23. By utilizing this mathematical verification, mock-jutsu ensures that every piece of test data produced will pass both front-end and back-end validation logic that relies on the modulus-23 check digit system. This level of precision prevents the common "garbage in, garbage out" problem often encountered when using random strings for sensitive ID fields during the development lifecycle.
Integrating this function into a modern development workflow is remarkably versatile. Developers can trigger the generation via the command line using mockjutsu generate es_dni, or embed it directly into automated Python scripts with jutsu.generate('es_dni'). For performance testers, the library even supports JMeter integration through the ${__mockjutsu(es_dni,)} syntax. This flexibility allows teams to populate staging databases, automate API tests, or simulate high-load user registrations with high-fidelity test data that mirrors the exact format of a Spanish national ID, such as 12345678Z.
Beyond simple validation, using es_dni offers significant benefits for UI/UX testing and regulatory compliance simulations. It allows QA engineers to verify that input masks correctly handle the transition from digits to letters and that error handling triggers appropriately for invalid formats. By using mock-jutsu to automate the creation of these identifiers, development teams save countless hours that would otherwise be spent manually calculating valid check letters or searching for placeholder values, ultimately accelerating the delivery of robust, localized software solutions.
mockjutsu generate es_dnimockjutsu bulk es_dni --count 10mockjutsu export es_dni --count 10 --format jsonmockjutsu export es_dni --count 10 --format csvmockjutsu export es_dni --count 10 --format sql# --mask: regulation-compliant output (PCI DSS / GDPR / KVKK)mockjutsu generate es_dni --maskmockjutsu bulk es_dni --count 5 --maskfrom mockjutsu import jutsujutsu.generate('es_dni')jutsu.bulk('es_dni', count=10)jutsu.template(['es_dni'], count=5)# mask=True: regulation-compliant outputjutsu.generate('es_dni', mask=True)jutsu.bulk('es_dni', count=5, mask=True)${__mockjutsu_intl_ids(es_dni)}# JMeter Function: __mockjutsu_intl_ids# Parameter 1: es_dni# Parameter 2: (not required for this function)# Add 'mask' keyword to get a regulation-compliant masked value${__mockjutsu_intl_ids(es_dni,mask)}GET /generate/es_dni# → {"type":"es_dni","result":"...","status":"ok"}GET /bulk/es_dni?count=10POST /template {"types":["es_dni"],"count":1}# mask=true: regulation-compliant outputGET /generate/es_dni?mask=trueGET /bulk/es_dni?count=5&mask=true| Parameter | Values | Description |
|---|---|---|
| --mask | true | false | Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…) |