Costa Rica DIMEX Validator (Foreigner ID / DGME)
Validate the structural syntax, prefix rules, and digit length of 11-digit and 12-digit Costa Rican DIMEX numbers.
How does Costa Rica DIMEX validation work?
The validator checks that the string contains 11 or 12 decimal digits, starts with '1' indicating a migration registry document, and is not composed of all identical or all zero digits.
Both plain numeric inputs and hyphenated formats (e.g. 1172-00012345) are accepted.
DIMEX Structure
Composition of the 11 or 12 digits:
| Position | Field | Length | Meaning | Example |
|---|---|---|---|---|
| 1-3 | Category | 3 digits | Official DGME prefix | 117 |
| 4-11/12 | Sequential | 8 or 9 digits | Registry sequential number | 200012345 |
Validation Algorithm
Rules checked by the validator:
Length = 11 or 12 digits
- 1. Remove hyphens and whitespace characters.
- 2. Confirm digit count is either 11 or 12.
- 3. Verify initial digit is '1'.
- 4. Reject repeated single digits.
- 5. Reject all-zero sequential suffixes.