es_dniIntlIDs

Mock Jutsu HOW-TO | UK

The es_dni function serves as a specialised tool within the mock-jutsu library, specifically engineered to produce authentic Spanish National Identity Document numbers. In the realm of software development, particularly when building applications for the Iberian market, having access to accurate test data is paramount for ensuring system integrity. This function generates a string comprising eight numerical digits followed by a single control letter, adhering strictly to the formatting requirements used by Spanish authorities. By integrating this utility into your testing workflow, you ensure that your application’s data layer remains robust and representative of real-world inputs.

Under the hood, the es_dni generator employs the official MOD-23 algorithm to determine the trailing checksum character. This mathematical validation involves dividing the eight-digit number by 23 and mapping the remainder to a specific set of standardised letters, excluding characters like I, O, and U to prevent visual confusion. Because mock-jutsu implements this exact logic, the generated mock data is indistinguishable from genuine identification numbers to most validation scripts. This level of precision is essential for developers who need to bypass front-end validation filters or test database constraints that require mathematically valid identifiers for successful record insertion.

The versatility of es_dni makes it an indispensable asset for various testing scenarios across the software development lifecycle. Whether you are performing manual QA via the command line, automating unit tests within a Python environment, or conducting high-concurrency performance testing using JMeter, the function provides consistent and reliable results. It is particularly useful for populating user registration forms, verifying KYC (Know Your Customer) workflows, or testing financial transaction systems where a DNI is a mandatory field. By using high-quality test data, teams can identify edge cases and validation errors early, significantly reducing the risk of production bugs.

Beyond its technical accuracy, es_dni offers a streamlined developer experience that prioritises efficiency. With simple syntax across different platforms—ranging from a quick CLI command to a direct Python call using jutsu.generate—the function eliminates the need for manual data entry or the creation of complex custom regex generators. This efficiency allows engineering teams to focus on core logic rather than the minutiae of data synthesisation. Ultimately, mock-jutsu empowers developers to build better, more reliable software by providing a standardised, easy-to-use solution for generating complex regional identifiers.

CLI Usage
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 --mask
Python API
from 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)
JMeter
${__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)}
REST API
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

Parameters

Parameter Values Description
--mask true | false Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…)

Other Languages