Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Overhauled Venezuela's countryData to use three levels of administrative subdivisions and include several missing ZIP codes.

## [3.42.0] - 2025-12-09

### Added
Expand Down
262 changes: 39 additions & 223 deletions react/country/VEN.ts
Original file line number Diff line number Diff line change
@@ -1,229 +1,19 @@
import { TWO_LEVELS } from '../constants'
import { secondLevelPostalCodes } from '../transforms/postalCodes'
import { getOneLevel, getTwoLevels } from '../transforms/addressFieldsOptions'
import { THREE_LEVELS } from '../constants'
import { thirdLevelPostalCodes } from '../transforms/postalCodes'
import {
getOneLevel,
getTwoLevels,
getThreeLevels,
} from '../transforms/addressFieldsOptions'
import type { PostalCodeRules } from '../types/rules'

const countryData = {
Apure: {
Achaguas: '7002',
Biruaca: '7007',
'Muñoz': '7005',
'Páez': '5063',
'Pedro Camejo': '7004',
'Rómulo Gallegos': '7011',
'San Fernando': '7001',
},
Anzoategui: {
'Anaco ': '6001',
'Aragua ': '6002',
'Simón Bolivar ': '6003',
'San Juan de Capristano': '6004',
'Pedro María Freites': '6005',
'Manuel Ezequiel Bruzual': '6006',
'Sir Arthur Mc Gregor ': '6007',
'Simón Rodriguez': '6008',
Guanta: '6009',
'Diego Bautista Urbaneja': '6010',
'Jose Gregorio Monagas': '6011',
'Juan Manuel Cajigal': '6012',
'Francisco de Miranda ': '6013',
'Píritu ': '6014',
'Juan Antonio Sotillo': '6015',
'Fernando de Peñalver': '6016',
'San Jose de Guanipa/Guanipa': '6017',
Libertad: '6018',
'Santa Ana ': '6019',
'Indpendencia ': '6020',
'Francisco del Carmen Carvajal ': '6021',
},
Aragua: {
Urdaneta: '2335',
Sucre: '2336',
Camatagua: '2337',
'Jose Rafael Revenga': '2338',
'Jose Felix Ribas': '2339',
Girardot: '2340',
'Libertador ': '2341',
'San casimiro': '2342',
Bolivar: '2343',
'San Sebastian': '2344',
'Jose Angel Lamas': '2345',
Zamora: '2346',
},
Barinas: {
'Barinas ': '5201',
'Bolívar ': '5202',
'Cruz Paredes': '5203',
Pedraza: '5204',
'Rojas ': '5205',
Obispos: '5206',
'Alberto Arvelo Torrealba': '5207',
},
Bolívar: {
Heres: '5208',
},
Carabobo: {
Bejuma: '2040',
Guacara: '2041',
'Carlos Arvelo ': '2042',
'Los Guayos': '2043',
Miranda: '2044',
Montalbán: '2045',
'Juan José Mora': '2046',
Naguanagua: '2047',
'Puerto Cabello ': '2048',
'San Diego': '2049',
Libertador: '2050',
Valencia: '2051',
},
Cojedes: {
Anzoátegui: '2209',
Girardot: '2210',
'Pao de San Juan Bautista': '2211',
Ricaurte: '2212',
'Lima Blanco': '2213',
'San Carlos': '2214',
Tinaco: '2215',
},
'Distrito Capital': {
Libertador: '2216',
},
Falcón: {
Dabajuro: '2217',
Colina: '2218',
Miranda: '2219',
'Zamora ': '2220',
Carirubana: '2221',
},
Guárico: {
'José Tadeo Monagas': '2320',
'Francisco de Miranda': '2321',
Chaguaramas: '2322',
'El Socorro': '2323',
'Julián Mellado': '2324',
'San Gerónimo de Guayabal': '2325',
'Las Mercedes': '2326',
Ortíz: '2327',
'San José de Guaribe': '2328',
'Juan Germán Roscio': '2329',
'Santa María de Ipire': '2330',
'José Félix Ribas': '2331',
'Leonardo Infante': '2390',
},
Lara: {
Palavecino: '2391',
},
Mérida: {
'Rivas Dávila': '2392',
'Campo Elías': '2393',
Libertador: '2394',
Tovar: '2395',
},
Miranda: {
'Pedro Gual': '2396',
Carrizal: '2397',
Acevedo: '2398',
Chacao: '2399',
'Cristóbal Rojas': '2400',
'El Hatillo': '2401',
Plaza: '2402',
'Zamora ': '2403',
Brión: '2404',
Guaicaipuro: '2405',
Baruta: '2406',
Sucre: '2407',
'Los Salias': '2408',
'Simón Bolívar': '2409',
'Andrés Bello': '2410',
'Paz Castillo': '2411',
Independencia: '2412',
Urdaneta: '1211',
},
Monagas: {
Piar: '6200',
Sotillo: '6201',
Cedeño: '6202',
Caripe: '6203',
Maturín: '6204',
Acosta: '6205',
'Santa Bárbara': '6206',
},
'Nueva Esparta': {
'Península de Macanao': '6300',
Garcia: '6301',
Marcano: '6302',
Arismendi: '6303',
'Antolín del Campo': '6304',
Maneiro: '6306',
Mariño: '6311',
Tubores: '6312',
Díaz: '6313',
'Villalba ': '6314',
Gómez: '6315',
},
Portuguesa: {
Páez: '3300',
Araure: '3301',
Guanare: '3303',
},
Sucre: {
Sucre: '6500',
Montes: '6501',
Bolívar: '6502',
Mejía: '6503',
},
Táchira: {
Guásimos: '5015',
'San Cristobal': '5016',
Cárdenas: '5017',
Córdoba: '5018',
},
Trujillo: {
'Rafael Rangel': '3115',
Boconó: '3116',
'Juan Vicente Campo Elías': '3117',
Candelaria: '3118',
Miranda: '3119',
Motatán: '3120',
Pampán: '3121',
Sucre: '3122',
'La ceiba': '3123',
'Valera ': '3124',
},
Vargas: {
Vargas: '1162',
Caraballeda: '1165',
Carayaca: '1167',
'Catia La Mar': '1162',
'La Guaira': '1160',
'La Sabana': '1168',
Macuto: '1164',
Maiquetía: '1161',
Naiguatá: '1166',
},
Yaracuy: {
Bruzual: '3202',
'Independencia ': '3201',
Cocorote: '3203',
Sucre: '3204',
'José Antonio Páez': '3205',
'San Felipe': '3206',
'Arístides Bastidas': '3207',
Peña: '3208',
},
Zulia: {
Cabimas: '4013',
Maracaibo: '4014',
'San Francisco': '4015',
},
}
import countryData from './data/VEN.json'

const rules: PostalCodeRules = {
country: 'VEN',
abbr: 'VE',
postalCodeFrom: TWO_LEVELS,
postalCodeLevels: ['state', 'city'],
secondLevelPostalCodes: secondLevelPostalCodes(countryData),
postalCodeFrom: THREE_LEVELS,
postalCodeLevels: ['state', 'city', 'neighborhood'],
thirdLevelPostalCodes: thirdLevelPostalCodes(countryData),
fields: [
{
hidden: true,
Expand Down Expand Up @@ -281,7 +71,7 @@
},
{
name: 'city',
maxLength: 100,
maxLength: 150,
label: 'city',
required: true,
size: 'large',
Expand All @@ -291,10 +81,13 @@
},
{
name: 'neighborhood',
maxLength: 100,
maxLength: 150,
label: 'neighborhood',
required: true,
size: 'large',
level: 3,
basedOn: 'city',
optionsMap: getThreeLevels(countryData),
},
{
name: 'receiverName',
Expand All @@ -310,6 +103,29 @@
valueIn: 'long_name',
types: ['postal_code'],
required: false,
handler: (address) => {
if (!address.state || !address.city || !address.neighborhood) {
return address
}

if (
address.state.value &&
countryData[address.state.value] &&

Check warning on line 113 in react/country/VEN.ts

View check run for this annotation

Sonar - Workflows / SonarQube Code Analysis

react/country/VEN.ts#L113

Prefer using an optional chain expression instead, as it's more concise and easier to read.
countryData[address.state.value][address.city.value] &&
countryData[address.state.value][address.city.value][
address.neighborhood.value
]
) {
address.postalCode = {
value:
countryData[address.state.value][address.city.value][
address.neighborhood.value
],
}
}

return address
},
},

complement: {
Expand Down
Loading
Loading