diff --git a/src/CONST.js b/src/CONST.js index a13b69adac9d..f08cd326b035 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1111,264 +1111,1084 @@ const CONST = { USA_COUNTRY_NAME, SPACE_LENGTH: 1, SPACE: 1, + ALL_COUNTRIES: { - AC: 'Ascension Island', - AD: 'Andorra', - AE: 'United Arab Emirates', AF: 'Afghanistan', - AG: 'Antigua & Barbuda', - AI: 'Anguilla', + AX: 'Åland Islands', AL: 'Albania', - AM: 'Armenia', + DZ: 'Algeria', + AS: 'American Samoa', + AD: 'Andorra', AO: 'Angola', + AI: 'Anguilla', AQ: 'Antarctica', + AG: 'Antigua & Barbuda', AR: 'Argentina', - AS: 'American Samoa', - AT: 'Austria', - AU: 'Australia', + AM: 'Armenia', AW: 'Aruba', - AX: 'Åland Islands', + AC: 'Ascension Island', + AU: 'Australia', + AT: 'Austria', AZ: 'Azerbaijan', - BA: 'Bosnia & Herzegovina', - BB: 'Barbados', + BS: 'Bahamas', + BH: 'Bahrain', BD: 'Bangladesh', + BB: 'Barbados', + BY: 'Belarus', BE: 'Belgium', - BF: 'Burkina Faso', - BG: 'Bulgaria', - BH: 'Bahrain', - BI: 'Burundi', + BZ: 'Belize', BJ: 'Benin', - BL: 'St. Barthélemy', BM: 'Bermuda', - BN: 'Brunei', - BO: 'Bolivia', - BQ: 'Caribbean Netherlands', - BR: 'Brazil', - BS: 'Bahamas', BT: 'Bhutan', + BO: 'Bolivia', + BA: 'Bosnia & Herzegovina', BW: 'Botswana', - BY: 'Belarus', - BZ: 'Belize', + BR: 'Brazil', + IO: 'British Indian Ocean Territory', + VG: 'British Virgin Islands', + BN: 'Brunei', + BG: 'Bulgaria', + BF: 'Burkina Faso', + BI: 'Burundi', + KH: 'Cambodia', + CM: 'Cameroon', CA: 'Canada', - CC: 'Cocos (Keeling) Islands', - CD: 'Congo - Kinshasa', + CV: 'Cape Verde', + BQ: 'Caribbean Netherlands', + KY: 'Cayman Islands', CF: 'Central African Republic', - CG: 'Congo - Brazzaville', - CH: 'Switzerland', - CI: 'Côte d’Ivoire', - CK: 'Cook Islands', + TD: 'Chad', CL: 'Chile', - CM: 'Cameroon', CN: 'China', + CX: 'Christmas Island', + CC: 'Cocos (Keeling) Islands', CO: 'Colombia', + KM: 'Comoros', + CG: 'Congo - Brazzaville', + CD: 'Congo - Kinshasa', + CK: 'Cook Islands', CR: 'Costa Rica', + CI: 'Côte d\'Ivoire', + HR: 'Croatia', CU: 'Cuba', - CV: 'Cape Verde', CW: 'Curaçao', - CX: 'Christmas Island', CY: 'Cyprus', - CZ: 'Czechia', - DE: 'Germany', - DG: 'Diego Garcia', - DJ: 'Djibouti', + CZ: 'Czech Republic', DK: 'Denmark', + DJ: 'Djibouti', DM: 'Dominica', DO: 'Dominican Republic', - DZ: 'Algeria', - EA: 'Ceuta & Melilla', EC: 'Ecuador', - EE: 'Estonia', EG: 'Egypt', - EH: 'Western Sahara', + SV: 'El Salvador', + GQ: 'Equatorial Guinea', ER: 'Eritrea', - ES: 'Spain', + EE: 'Estonia', ET: 'Ethiopia', - EZ: 'Eurozone', - FI: 'Finland', - FJ: 'Fiji', FK: 'Falkland Islands', - FM: 'Micronesia', FO: 'Faroe Islands', + FJ: 'Fiji', + FI: 'Finland', FR: 'France', + GF: 'French Guiana', + PF: 'French Polynesia', + TF: 'French Southern Territories', GA: 'Gabon', - GB: 'United Kingdom', - GD: 'Grenada', + GM: 'Gambia', GE: 'Georgia', - GF: 'French Guiana', - GG: 'Guernsey', + DE: 'Germany', GH: 'Ghana', GI: 'Gibraltar', + GR: 'Greece', GL: 'Greenland', - GM: 'Gambia', - GN: 'Guinea', + GD: 'Grenada', GP: 'Guadeloupe', - GQ: 'Equatorial Guinea', - GR: 'Greece', - GS: 'South Georgia & South Sandwich Islands', - GT: 'Guatemala', GU: 'Guam', + GT: 'Guatemala', + GG: 'Guernsey', + GN: 'Guinea', GW: 'Guinea-Bissau', GY: 'Guyana', - HK: 'Hong Kong', - HN: 'Honduras', - HR: 'Croatia', HT: 'Haiti', + HN: 'Honduras', + HK: 'Hong Kong', HU: 'Hungary', - IC: 'Canary Islands', + IS: 'Iceland', + IN: 'India', ID: 'Indonesia', + IR: 'Iran', + IQ: 'Iraq', IE: 'Ireland', - IL: 'Israel', IM: 'Isle of Man', - IN: 'India', - IO: 'British Indian Ocean Territory', - IQ: 'Iraq', - IR: 'Iran', - IS: 'Iceland', + IL: 'Israel', IT: 'Italy', - JE: 'Jersey', JM: 'Jamaica', - JO: 'Jordan', JP: 'Japan', + JE: 'Jersey', + JO: 'Jordan', + KZ: 'Kazakhstan', KE: 'Kenya', - KG: 'Kyrgyzstan', - KH: 'Cambodia', KI: 'Kiribati', - KM: 'Comoros', - KN: 'St. Kitts & Nevis', - KP: 'North Korea', - KR: 'South Korea', + XK: 'Kosovo', KW: 'Kuwait', - KY: 'Cayman Islands', - KZ: 'Kazakhstan', + KG: 'Kyrgyzstan', LA: 'Laos', + LV: 'Latvia', LB: 'Lebanon', - LC: 'St. Lucia', - LI: 'Liechtenstein', - LK: 'Sri Lanka', - LR: 'Liberia', LS: 'Lesotho', + LR: 'Liberia', + LY: 'Libya', + LI: 'Liechtenstein', LT: 'Lithuania', LU: 'Luxembourg', - LV: 'Latvia', - LY: 'Libya', - MA: 'Morocco', - MC: 'Monaco', - MD: 'Moldova', - ME: 'Montenegro', - MF: 'St. Martin', - MG: 'Madagascar', - MH: 'Marshall Islands', + MO: 'Macau', MK: 'Macedonia', + MG: 'Madagascar', + MW: 'Malawi', + MY: 'Malaysia', + MV: 'Maldives', ML: 'Mali', - MM: 'Myanmar (Burma)', - MN: 'Mongolia', - MO: 'Macau', - MP: 'Northern Mariana Islands', + MT: 'Malta', + MH: 'Marshall Islands', MQ: 'Martinique', MR: 'Mauritania', - MS: 'Montserrat', - MT: 'Malta', MU: 'Mauritius', - MV: 'Maldives', - MW: 'Malawi', + YT: 'Mayotte', MX: 'Mexico', - MY: 'Malaysia', + FM: 'Micronesia', + MD: 'Moldova', + MC: 'Monaco', + MN: 'Mongolia', + ME: 'Montenegro', + MS: 'Montserrat', + MA: 'Morocco', MZ: 'Mozambique', + MM: 'Myanmar (Burma)', NA: 'Namibia', + NR: 'Nauru', + NP: 'Nepal', + NL: 'Netherlands', NC: 'New Caledonia', + NZ: 'New Zealand', + NI: 'Nicaragua', NE: 'Niger', - NF: 'Norfolk Island', NG: 'Nigeria', - NI: 'Nicaragua', - NL: 'Netherlands', - NO: 'Norway', - NP: 'Nepal', - NR: 'Nauru', NU: 'Niue', - NZ: 'New Zealand', + NF: 'Norfolk Island', + KP: 'North Korea', + MP: 'Northern Mariana Islands', + NO: 'Norway', OM: 'Oman', + PK: 'Pakistan', + PW: 'Palau', + PS: 'Palestinian Territories', PA: 'Panama', - PE: 'Peru', - PF: 'French Polynesia', PG: 'Papua New Guinea', + PY: 'Paraguay', + PE: 'Peru', PH: 'Philippines', - PK: 'Pakistan', - PL: 'Poland', - PM: 'St. Pierre & Miquelon', PN: 'Pitcairn Islands', - PR: 'Puerto Rico', - PS: 'Palestinian Territories', + PL: 'Poland', PT: 'Portugal', - PW: 'Palau', - PY: 'Paraguay', + PR: 'Puerto Rico', QA: 'Qatar', RE: 'Réunion', RO: 'Romania', - RS: 'Serbia', RU: 'Russia', RW: 'Rwanda', + BL: 'Saint Barthélemy', + WS: 'Samoa', + SM: 'San Marino', + ST: 'São Tomé & Príncipe', SA: 'Saudi Arabia', - SB: 'Solomon Islands', + SN: 'Senegal', + RS: 'Serbia', SC: 'Seychelles', - SD: 'Sudan', - SE: 'Sweden', + SL: 'Sierra Leone', SG: 'Singapore', - SH: 'St. Helena', - SI: 'Slovenia', - SJ: 'Svalbard & Jan Mayen', + SX: 'Sint Maarten', SK: 'Slovakia', - SL: 'Sierra Leone', - SM: 'San Marino', - SN: 'Senegal', + SI: 'Slovenia', + SB: 'Solomon Islands', SO: 'Somalia', - SR: 'Suriname', + ZA: 'South Africa', + GS: 'South Georgia & South Sandwich Islands', + KR: 'South Korea', SS: 'South Sudan', - ST: 'São Tomé & Príncipe', - SV: 'El Salvador', - SX: 'Sint Maarten', - SY: 'Syria', + ES: 'Spain', + LK: 'Sri Lanka', + SH: 'St. Helena', + KN: 'St. Kitts & Nevis', + LC: 'St. Lucia', + MF: 'St. Martin', + PM: 'St. Pierre & Miquelon', + VC: 'St. Vincent & Grenadines', + SD: 'Sudan', + SR: 'Suriname', + SJ: 'Svalbard & Jan Mayen', SZ: 'Swaziland', - TA: 'Tristan da Cunha', - TC: 'Turks & Caicos Islands', - TD: 'Chad', - TF: 'French Southern Territories', - TG: 'Togo', - TH: 'Thailand', + SE: 'Sweden', + CH: 'Switzerland', + SY: 'Syria', + TW: 'Taiwan', TJ: 'Tajikistan', - TK: 'Tokelau', + TZ: 'Tanzania', + TH: 'Thailand', TL: 'Timor-Leste', - TM: 'Turkmenistan', - TN: 'Tunisia', + TG: 'Togo', + TK: 'Tokelau', TO: 'Tonga', - TR: 'Turkey', TT: 'Trinidad & Tobago', + TA: 'Tristan da Cunha', + TN: 'Tunisia', + TR: 'Turkey', + TM: 'Turkmenistan', + TC: 'Turks & Caicos Islands', TV: 'Tuvalu', - TW: 'Taiwan', - TZ: 'Tanzania', - UA: 'Ukraine', - UG: 'Uganda', UM: 'U.S. Outlying Islands', - UN: 'United Nations', + VI: 'U.S. Virgin Islands', + UG: 'Uganda', + UA: 'Ukraine', + AE: 'United Arab Emirates', + GB: 'United Kingdom', US: 'United States', UY: 'Uruguay', UZ: 'Uzbekistan', + VU: 'Vanuatu', VA: 'Vatican City', - VC: 'St. Vincent & Grenadines', VE: 'Venezuela', - VG: 'British Virgin Islands', - VI: 'U.S. Virgin Islands', VN: 'Vietnam', - VU: 'Vanuatu', WF: 'Wallis & Futuna', - WS: 'Samoa', - XK: 'Kosovo', + EH: 'Western Sahara', YE: 'Yemen', - YT: 'Mayotte', - ZA: 'South Africa', ZM: 'Zambia', ZW: 'Zimbabwe', }, + // Sources: https://github.com/Expensify/App/issues/14958#issuecomment-1442138427 + // https://github.com/Expensify/App/issues/14958#issuecomment-1456026810 + COUNTRY_ZIP_REGEX_DATA: { + AC: { + regex: /^ASCN 1ZZ$/, + samples: 'ASCN 1ZZ', + }, + AD: { + regex: /^AD[1-7]0\d$/, + samples: 'AD206, AD403, AD106, AD406', + }, + + // We have kept the empty object for the countries which do not have any zip code validation + // to ensure consistency so that the amount of countries displayed and in this object are same + AE: {}, + AF: { + regex: /^\d{4}$/, + samples: '9536, 1476, 3842, 7975', + }, + AG: {}, + AI: { + regex: /^AI-2640$/, + samples: 'AI-2640', + }, + AL: { + regex: /^\d{4}$/, + samples: '1631, 9721, 2360, 5574', + }, + AM: { + regex: /^\d{4}$/, + samples: '5581, 7585, 8434, 2492', + }, + AO: {}, + AQ: {}, + AR: { + regex: /^((?:[A-HJ-NP-Z])?\d{4})([A-Z]{3})?$/, + samples: 'Q7040GFQ, K2178ZHR, P6240EJG, J6070IAE', + }, + AS: { + regex: /^96799$/, + samples: '96799', + }, + AT: { + regex: /^\d{4}$/, + samples: '4223, 2052, 3544, 5488', + }, + AU: { + regex: /^\d{4}$/, + samples: '7181, 7735, 9169, 8780', + }, + AW: {}, + AX: { + regex: /^22\d{3}$/, + samples: '22270, 22889, 22906, 22284', + }, + AZ: { + regex: /^(AZ) (\d{4})$/, + samples: 'AZ 6704, AZ 5332, AZ 3907, AZ 6892', + }, + BA: { + regex: /^\d{5}$/, + samples: '62722, 80420, 44595, 74614', + }, + BB: { + regex: /^BB\d{5}$/, + samples: 'BB64089, BB17494, BB73163, BB25752', + }, + BD: { + regex: /^\d{4}$/, + samples: '8585, 8175, 7381, 0154', + }, + BE: { + regex: /^\d{4}$/, + samples: '7944, 5303, 6746, 7921', + }, + BF: {}, + BG: { + regex: /^\d{4}$/, + samples: '6409, 7657, 1206, 7908', + }, + BH: { + regex: /^\d{3}\d?$/, + samples: '047, 1116, 490, 631', + }, + BI: {}, + BJ: {}, + BL: { + regex: /^97133$/, + samples: '97133', + }, + BM: { + regex: /^[A-Z]{2} ?[A-Z0-9]{2}$/, + samples: 'QV9P, OSJ1, PZ 3D, GR YK', + }, + BN: { + regex: /^[A-Z]{2} ?\d{4}$/, + samples: 'PF 9925, TH1970, SC 4619, NF0781', + }, + BO: {}, + BQ: {}, + BR: { + regex: /^\d{5}-?\d{3}$/, + samples: '18816-403, 95177-465, 43447-782, 39403-136', + }, + BS: {}, + BT: { + regex: /^\d{5}$/, + samples: '28256, 52484, 30608, 93524', + }, + BW: {}, + BY: { + regex: /^\d{6}$/, + samples: '504154, 360246, 741167, 895047', + }, + BZ: {}, + CA: { + regex: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] ?\d[ABCEGHJ-NPRSTV-Z]\d$/, + samples: 'S1A7K8, Y5H 4G6, H9V0P2, H1A1B5', + }, + CC: { + regex: /^6799$/, + samples: '6799', + }, + CD: {}, + CF: {}, + CG: {}, + CH: { + regex: /^\d{4}$/, + samples: '6370, 5271, 7873, 8220', + }, + CI: {}, + CK: {}, + CL: { + regex: /^\d{7}$/, + samples: '7565829, 8702008, 3161669, 1607703', + }, + CM: {}, + CN: { + regex: /^\d{6}$/, + samples: '240543, 870138, 295528, 861683', + }, + CO: { + regex: /^\d{6}$/, + samples: '678978, 775145, 823943, 913970', + }, + CR: { + regex: /^\d{5}$/, + samples: '28256, 52484, 30608, 93524', + }, + CU: { + regex: /^(?:CP)?(\d{5})$/, + samples: '28256, 52484, 30608, 93524', + }, + CV: { + regex: /^\d{4}$/, + samples: '9056, 8085, 0491, 4627', + }, + CW: {}, + CX: { + regex: /^6798$/, + samples: '6798', + }, + CY: { + regex: /^\d{4}$/, + samples: '9301, 2478, 1981, 6162', + }, + CZ: { + regex: /^\d{3} ?\d{2}$/, + samples: '150 56, 50694, 229 08, 82811', + }, + DE: { + regex: /^\d{5}$/, + samples: '33185, 37198, 81711, 44262', + }, + DJ: {}, + DK: { + regex: /^\d{4}$/, + samples: '1429, 2457, 0637, 5764', + }, + DM: {}, + DO: { + regex: /^\d{5}$/, + samples: '11877, 95773, 93875, 98032', + }, + DZ: { + regex: /^\d{5}$/, + samples: '26581, 64621, 57550, 72201', + }, + EC: { + regex: /^\d{6}$/, + samples: '541124, 873848, 011495, 334509', + }, + EE: { + regex: /^\d{5}$/, + samples: '87173, 01127, 73214, 52381', + }, + EG: { + regex: /^\d{5}$/, + samples: '98394, 05129, 91463, 77359', + }, + EH: { + regex: /^\d{5}$/, + samples: '30577, 60264, 16487, 38593', + }, + ER: {}, + ES: { + regex: /^\d{5}$/, + samples: '03315, 00413, 23179, 89324', + }, + ET: { + regex: /^\d{4}$/, + samples: '6269, 8498, 4514, 7820', + }, + FI: { + regex: /^\d{5}$/, + samples: '21859, 72086, 22422, 03774', + }, + FJ: {}, + FK: { + regex: /^FIQQ 1ZZ$/, + samples: 'FIQQ 1ZZ', + }, + FM: { + regex: /^(9694[1-4])(?:[ -](\d{4}))?$/, + samples: '96942-9352, 96944-4935, 96941 9065, 96943-5369', + }, + FO: { + regex: /^\d{3}$/, + samples: '334, 068, 741, 787', + }, + FR: { + regex: /^\d{2} ?\d{3}$/, + samples: '25822, 53 637, 55354, 82522', + }, + GA: {}, + GB: { + regex: /^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-CIKMOV]{2}$/, + samples: 'LA102UX, BL2F8FX, BD1S9LU, WR4G 6LH', + }, + GD: {}, + GE: { + regex: /^\d{4}$/, + samples: '1232, 9831, 4717, 9428', + }, + GF: { + regex: /^9[78]3\d{2}$/, + samples: '98380, 97335, 98344, 97300', + }, + GG: { + regex: /^GY\d[\dA-Z]? ?\d[ABD-HJLN-UW-Z]{2}$/, + samples: 'GY757LD, GY6D 6XL, GY3Y2BU, GY85 1YO', + }, + GH: {}, + GI: { + regex: /^GX11 1AA$/, + samples: 'GX11 1AA', + }, + GL: { + regex: /^39\d{2}$/, + samples: '3964, 3915, 3963, 3956', + }, + GM: {}, + GN: { + regex: /^\d{3}$/, + samples: '465, 994, 333, 078', + }, + GP: { + regex: /^9[78][01]\d{2}$/, + samples: '98069, 97007, 97147, 97106', + }, + GQ: {}, + GR: { + regex: /^\d{3} ?\d{2}$/, + samples: '98654, 319 78, 127 09, 590 52', + }, + GS: { + regex: /^SIQQ 1ZZ$/, + samples: 'SIQQ 1ZZ', + }, + GT: { + regex: /^\d{5}$/, + samples: '30553, 69925, 09376, 83719', + }, + GU: { + regex: /^((969)[1-3][0-2])$/, + samples: '96922, 96932, 96921, 96911', + }, + GW: { + regex: /^\d{4}$/, + samples: '1742, 7941, 4437, 7728', + }, + GY: {}, + HK: { + regex: /^999077$|^$/, + samples: '999077, empty', + }, + HN: { + regex: /^\d{5}$/, + samples: '86238, 78999, 03594, 30406', + }, + HR: { + regex: /^\d{5}$/, + samples: '85240, 80710, 78235, 98766', + }, + HT: { + regex: /^(?:HT)?(\d{4})$/, + samples: '5101, HT6991, HT3871, 1126', + }, + HU: { + regex: /^\d{4}$/, + samples: '0360, 2604, 3362, 4775', + }, + ID: { + regex: /^\d{5}$/, + samples: '60993, 52656, 16521, 34931', + }, + IE: {}, + IL: { + regex: /^\d{5}(?:\d{2})?$/, + samples: '74213, 6978354, 2441689, 4971551', + }, + IM: { + regex: /^IM\d[\dA-Z]? ?\d[ABD-HJLN-UW-Z]{2}$/, + samples: 'IM2X1JP, IM4V 9JU, IM3B1UP, IM8E 5XF', + }, + IN: { + regex: /^\d{6}$/, + samples: '946956, 143659, 243258, 938385', + }, + IO: { + regex: /^BBND 1ZZ$/, + samples: 'BBND 1ZZ', + }, + IQ: { + regex: /^\d{5}$/, + samples: '63282, 87817, 38580, 47725', + }, + IR: { + regex: /^\d{5}-?\d{5}$/, + samples: '0666174250, 6052682188, 02360-81920, 25102-08646', + }, + IS: { + regex: /^\d{3}$/, + samples: '408, 013, 001, 936', + }, + IT: { + regex: /^\d{5}$/, + samples: '31701, 61341, 92781, 45609', + }, + JE: { + regex: /^JE\d[\dA-Z]? ?\d[ABD-HJLN-UW-Z]{2}$/, + samples: 'JE0D 2EX, JE59 2OF, JE1X1ZW, JE0V 1SO', + }, + JM: {}, + JO: { + regex: /^\d{5}$/, + samples: '20789, 02128, 52170, 40284', + }, + JP: { + regex: /^\d{3}-?\d{4}$/, + samples: '5429642, 046-1544, 6463599, 368-5362', + }, + KE: { + regex: /^\d{5}$/, + samples: '33043, 98830, 59324, 42876', + }, + KG: { + regex: /^\d{6}$/, + samples: '500371, 176592, 184133, 225279', + }, + KH: { + regex: /^\d{5,6}$/, + samples: '220281, 18824, 35379, 09570', + }, + KI: { + regex: /^KI\d{4}$/, + samples: '36524, 49717, 67606, 96469', + }, + KM: {}, + KN: { + regex: /^KN\d{4}(-\d{4})?$/, + samples: 'KN2522, KN2560-3032, KN3507, KN4440', + }, + KP: {}, + KR: { + regex: /^\d{5}$/, + samples: '67417, 66648, 08359, 93750', + }, + KW: { + regex: /^\d{5}$/, + samples: '74840, 53309, 71276, 59262', + }, + KY: { + regex: /^KY\d-\d{4}$/, + samples: 'KY0-3078, KY1-7812, KY8-3729, KY3-4664', + }, + KZ: { + regex: /^\d{6}$/, + samples: '129113, 976562, 226811, 933781', + }, + LA: { + regex: /^\d{5}$/, + samples: '08875, 50779, 87756, 75932', + }, + LB: { + regex: /^(?:\d{4})(?: ?(?:\d{4}))?$/, + samples: '5436 1302, 9830 7470, 76911911, 9453 1306', + }, + LC: { + regex: /^(LC)?\d{2} ?\d{3}$/, + samples: '21080, LC99127, LC24 258, 51 740', + }, + LI: { + regex: /^\d{4}$/, + samples: '6644, 2852, 4630, 4541', + }, + LK: { + regex: /^\d{5}$/, + samples: '44605, 27721, 90695, 65514', + }, + LR: { + regex: /^\d{4}$/, + samples: '6644, 2852, 4630, 4541', + }, + LS: { + regex: /^\d{3}$/, + samples: '779, 803, 104, 897', + }, + LT: { + regex: /^((LT)[-])?(\d{5})$/, + samples: 'LT-22248, LT-12796, 69822, 37280', + }, + LU: { + regex: /^((L)[-])?(\d{4})$/, + samples: '5469, L-4476, 6304, 9739', + }, + LV: { + regex: /^((LV)[-])?\d{4}$/, + samples: '9344, LV-5030, LV-0132, 8097', + }, + LY: {}, + MA: { + regex: /^\d{5}$/, + samples: '50219, 95871, 80907, 79804', + }, + MC: { + regex: /^980\d{2}$/, + samples: '98084, 98041, 98070, 98062', + }, + MD: { + regex: /^(MD[-]?)?(\d{4})$/, + samples: '6250, MD-9681, MD3282, MD-0652', + }, + ME: { + regex: /^\d{5}$/, + samples: '87622, 92688, 23129, 59566', + }, + MF: { + regex: /^9[78][01]\d{2}$/, + samples: '97169, 98180, 98067, 98043', + }, + MG: { + regex: /^\d{3}$/, + samples: '854, 084, 524, 064', + }, + MH: { + regex: /^((969)[6-7][0-9])(-\d{4})?/, + samples: '96962, 96969, 96970-8530, 96960-3226', + }, + MK: { + regex: /^\d{4}$/, + samples: '8299, 6904, 6144, 9753', + }, + ML: {}, + MM: { + regex: /^\d{5}$/, + samples: '59188, 93943, 40829, 69981', + }, + MN: { + regex: /^\d{5}$/, + samples: '94129, 29906, 53374, 80141', + }, + MO: {}, + MP: { + regex: /^(9695[012])(?:[ -](\d{4}))?$/, + samples: '96952 3162, 96950 1567, 96951 2994, 96950 8745', + }, + MQ: { + regex: /^9[78]2\d{2}$/, + samples: '98297, 97273, 97261, 98282', + }, + MR: {}, + MS: { + regex: /^[Mm][Ss][Rr]\s{0,1}\d{4}$/, + samples: '97263, 97243, 98210, 97213', + }, + MT: { + regex: /^[A-Z]{3} [0-9]{4}|[A-Z]{2}[0-9]{2}|[A-Z]{2} [0-9]{2}|[A-Z]{3}[0-9]{4}|[A-Z]{3}[0-9]{2}|[A-Z]{3} [0-9]{2}$/, + samples: 'DKV 8196, KSU9264, QII0259, HKH 1020', + }, + MU: { + regex: /^([0-9A-R]\d{4})$/, + samples: 'H8310, 52591, M9826, F5810', + }, + MV: { + regex: /^\d{5}$/, + samples: '16354, 20857, 50991, 72527', + }, + MW: {}, + MX: { + regex: /^\d{5}$/, + samples: '71530, 76424, 73811, 50503', + }, + MY: { + regex: /^\d{5}$/, + samples: '75958, 15826, 86715, 37081', + }, + MZ: { + regex: /^\d{4}$/, + samples: '0902, 6258, 7826, 7150', + }, + NA: { + regex: /^\d{5}$/, + samples: '68338, 63392, 21820, 61211', + }, + NC: { + regex: /^988\d{2}$/, + samples: '98865, 98813, 98820, 98855', + }, + NE: { + regex: /^\d{4}$/, + samples: '9790, 3270, 2239, 0400', + }, + NF: { + regex: /^2899$/, + samples: '2899', + }, + NG: { + regex: /^\d{6}$/, + samples: '289096, 223817, 199970, 840648', + }, + NI: { + regex: /^\d{5}$/, + samples: '86308, 60956, 49945, 15470', + }, + NL: { + regex: /^\d{4} ?[A-Z]{2}$/, + samples: '6998 VY, 5390 CK, 2476 PS, 8873OX', + }, + NO: { + regex: /^\d{4}$/, + samples: '0711, 4104, 2683, 5015', + }, + NP: { + regex: /^\d{5}$/, + samples: '42438, 73964, 66400, 33976', + }, + NR: { + regex: /^(NRU68)$/, + samples: 'NRU68', + }, + NU: { + regex: /^(9974)$/, + samples: '9974', + }, + NZ: { + regex: /^\d{4}$/, + samples: '7015, 0780, 4109, 1422', + }, + OM: { + regex: /^(?:PC )?\d{3}$/, + samples: 'PC 851, PC 362, PC 598, PC 499', + }, + PA: { + regex: /^\d{4}$/, + samples: '0711, 4104, 2683, 5015', + }, + PE: { + regex: /^\d{5}$/, + samples: '10013, 12081, 14833, 24615', + }, + PF: { + regex: /^987\d{2}$/, + samples: '98755, 98710, 98748, 98791', + }, + PG: { + regex: /^\d{3}$/, + samples: '193, 166, 880, 553', + }, + PH: { + regex: /^\d{4}$/, + samples: '0137, 8216, 2876, 0876', + }, + PK: { + regex: /^\d{5}$/, + samples: '78219, 84497, 62102, 12564', + }, + PL: { + regex: /^\d{2}-\d{3}$/, + samples: '63-825, 26-714, 05-505, 15-200', + }, + PM: { + regex: /^(97500)$/, + samples: '97500', + }, + PN: { + regex: /^PCRN 1ZZ$/, + samples: 'PCRN 1ZZ', + }, + PR: { + regex: /^(00[679]\d{2})(?:[ -](\d{4}))?$/, + samples: '00989 3603, 00639 0720, 00707-9803, 00610 7362', + }, + PS: { + regex: /^(00[679]\d{2})(?:[ -](\d{4}))?$/, + samples: '00748, 00663, 00779-4433, 00934 1559', + }, + PT: { + regex: /^\d{4}-\d{3}$/, + samples: '0060-917, 4391-979, 5551-657, 9961-093', + }, + PW: { + regex: /^(969(?:39|40))(?:[ -](\d{4}))?$/, + samples: '96940, 96939, 96939 6004, 96940-1871', + }, + PY: { + regex: /^\d{4}$/, + samples: '7895, 5835, 8783, 5887', + }, + QA: {}, + RE: { + regex: /^9[78]4\d{2}$/, + samples: '98445, 97404, 98421, 98434', + }, + RO: { + regex: /^\d{6}$/, + samples: '935929, 407608, 637434, 174574', + }, + RS: { + regex: /^\d{5,6}$/, + samples: '929863, 259131, 687739, 07011', + }, + RU: { + regex: /^\d{6}$/, + samples: '138294, 617323, 307906, 981238', + }, + RW: {}, + SA: { + regex: /^\d{5}(-{1}\d{4})?$/, + samples: '86020-12567, 72375, 70280, 96328', + }, + SB: {}, + SC: {}, + SD: { + regex: /^\d{5}$/, + samples: '78219, 84497, 62102, 12564', + }, + SE: { + regex: /^\d{3} ?\d{2}$/, + samples: '095 39, 41052, 84687, 563 66', + }, + SG: { + regex: /^\d{6}$/, + samples: '606542, 233985, 036755, 265255', + }, + SH: { + regex: /^(?:ASCN|TDCU|STHL) 1ZZ$/, + samples: 'STHL 1ZZ, ASCN 1ZZ, TDCU 1ZZ', + }, + SI: { + regex: /^\d{4}$/, + samples: '6898, 3413, 2031, 5732', + }, + SJ: { + regex: /^\d{4}$/, + samples: '7616, 3163, 5769, 0237', + }, + SK: { + regex: /^\d{3} ?\d{2}$/, + samples: '594 52, 813 34, 867 67, 41814', + }, + SL: {}, + SM: { + regex: /^4789\d$/, + samples: '47894, 47895, 47893, 47899', + }, + SN: { + regex: /^[1-8]\d{4}$/, + samples: '48336, 23224, 33261, 82430', + }, + SO: {}, + SR: {}, + SS: { + regex: /^[A-Z]{2} ?\d{5}$/, + samples: 'JQ 80186, CU 46474, DE33738, MS 59107', + }, + ST: { + regex: /^[A-Z]{2} ?\d{5}$/, + samples: '87849, 89861, AG 93268, RC88066', + }, + SV: {}, + SX: {}, + SY: {}, + SZ: { + regex: /^[HLMS]\d{3}$/, + samples: 'H458, L986, M477, S916', + }, + TA: { + regex: /^TDCU 1ZZ$/, + samples: 'TDCU 1ZZ', + }, + TC: { + regex: /^TKCA 1ZZ$/, + samples: 'TKCA 1ZZ', + }, + TD: {}, + TF: {}, + TG: {}, + TH: { + regex: /^\d{5}$/, + samples: '30706, 18695, 21044, 42496', + }, + TJ: { + regex: /^\d{6}$/, + samples: '381098, 961344, 519925, 667883', + }, + TK: {}, + TL: {}, + TM: { + regex: /^\d{6}$/, + samples: '544985, 164362, 425224, 374603', + }, + TN: { + regex: /^\d{4}$/, + samples: '6075, 7340, 2574, 8988', + }, + TO: {}, + TR: { + regex: /^\d{5}$/, + samples: '42524, 81057, 50859, 42677', + }, + TT: { + regex: /^\d{6}$/, + samples: '041238, 033990, 763476, 981118', + }, + TV: {}, + TW: { + regex: /^\d{3}(?:\d{2})?$/, + samples: '21577, 76068, 68698, 08912', + }, + TZ: {}, + UA: { + regex: /^\d{5}$/, + samples: '10629, 81138, 15668, 30055', + }, + UG: {}, + UM: {}, + US: { + regex: /^[0-9]{5}(?:[- ][0-9]{4})?$/, + samples: '12345, 12345-1234, 12345 1234', + }, + UY: { + regex: /^\d{5}$/, + samples: '40073, 30136, 06583, 00021', + }, + UZ: { + regex: /^\d{6}$/, + samples: '205122, 219713, 441699, 287471', + }, + VA: { + regex: /^(00120)$/, + samples: '00120', + }, + VC: { + regex: /^VC\d{4}$/, + samples: 'VC0600, VC0176, VC0616, VC4094', + }, + VE: { + regex: /^\d{4}$/, + samples: '9692, 1953, 6680, 8302', + }, + VG: { + regex: /^VG\d{4}$/, + samples: 'VG1204, VG7387, VG3431, VG6021', + }, + VI: { + regex: /^(008(?:(?:[0-4]\d)|(?:5[01])))(?:[ -](\d{4}))?$/, + samples: '00820, 00804 2036, 00825 3344, 00811-5900', + }, + VN: { + regex: /^\d{6}$/, + samples: '133836, 748243, 894060, 020597', + }, + VU: {}, + WF: { + regex: /^986\d{2}$/, + samples: '98692, 98697, 98698, 98671', + }, + WS: { + regex: /^WS[1-2]\d{3}$/, + samples: 'WS1349, WS2798, WS1751, WS2090', + }, + XK: { + regex: /^[1-7]\d{4}$/, + samples: '56509, 15863, 46644, 21896', + }, + YE: {}, + YT: { + regex: /^976\d{2}$/, + samples: '97698, 97697, 97632, 97609', + }, + ZA: { + regex: /^\d{4}$/, + samples: '6855, 5179, 6956, 7147', + }, + ZM: { + regex: /^\d{5}$/, + samples: '77603, 97367, 80454, 94484', + }, + ZW: {}, + }, + + GENERIC_ZIP_CODE_REGEX: /^(?:(?![\s-])[\w -]{0,9}[\w])?$/, + // Values for checking if polyfill is required on a platform POLYFILL_TEST: { STYLE: 'currency', diff --git a/src/languages/en.js b/src/languages/en.js index 8c57c7629463..b10e88e7b2e1 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -128,6 +128,7 @@ export default { yesContinue: 'Yes, continue', zipCodeExample: 'e.g. 12345, 12345-1234, 12345 1234', websiteExample: 'e.g. https://www.expensify.com', + format: ({zipSampleFormat}) => (zipSampleFormat ? `Format: ${zipSampleFormat}` : ''), }, attachmentPicker: { cameraPermissionRequired: 'Camera access', @@ -649,6 +650,7 @@ export default { dateShouldBeBefore: ({dateString}) => `Date should be before ${dateString}.`, dateShouldBeAfter: ({dateString}) => `Date should be after ${dateString}.`, hasInvalidCharacter: 'Name can only include letters and numbers.', + incorrectZipFormat: ({zipFormat}) => `Incorrect zip code format.${zipFormat ? ` Acceptable format: ${zipFormat}` : ''}`, }, }, resendValidationForm: { diff --git a/src/languages/es.js b/src/languages/es.js index 5a0c7110cabe..41012e774550 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -127,6 +127,7 @@ export default { yesContinue: 'Sí, Continuar', zipCodeExample: 'p. ej. 12345, 12345-1234, 12345 1234', websiteExample: 'p. ej. https://www.expensify.com', + format: ({zipSampleFormat}) => (zipSampleFormat ? `Formato: ${zipSampleFormat}` : ''), }, attachmentPicker: { cameraPermissionRequired: 'Permiso para acceder a la cámara', @@ -647,6 +648,7 @@ export default { error: { dateShouldBeBefore: ({dateString}) => `La fecha debe ser anterior a ${dateString}.`, dateShouldBeAfter: ({dateString}) => `La fecha debe ser posterior a ${dateString}.`, + incorrectZipFormat: ({zipFormat}) => `Formato de código postal incorrecto.${zipFormat ? ` Formato aceptable: ${zipFormat}` : ''}`, hasInvalidCharacter: 'El nombre solo puede contener letras y números.', }, }, @@ -1438,259 +1440,254 @@ export default { }, }, allCountries: { - AC: 'Isla Ascensión', - AD: 'Andorra', - AE: 'Emiratos Árabes Unidos', AF: 'Afganistán', - AG: 'Antigua y Barbuda', - AI: 'Anguila', AL: 'Albania', - AM: 'Armenia', + DE: 'Alemania', + AD: 'Andorra', AO: 'Angola', + AI: 'Anguila', AQ: 'Antártida', + AG: 'Antigua y Barbuda', + SA: 'Arabia Saudita', + DZ: 'Argelia', AR: 'Argentina', - AS: 'Samoa Americana', - AT: 'Austria', - AU: 'Australia', + AM: 'Armenia', AW: 'Aruba', - AX: 'Islas de Åland', + AU: 'Australia', + AT: 'Austria', AZ: 'Azerbaiyán', - BA: 'Bosnia y Herzegovina', - BB: 'Barbados', + BS: 'Bahamas', + BH: 'Bahrein', BD: 'Bangladesh', + BB: 'Barbados', BE: 'Bélgica', - BF: 'Burkina Faso', - BG: 'Bulgaria', - BH: 'Bahrein', - BI: 'Burundi', + BZ: 'Belice', BJ: 'Benin', - BL: 'San Bartolomé', - BM: 'Islas Bermudas', - BN: 'Brunéi', + BT: 'Bhután', + BY: 'Bielorrusia', + MM: 'Birmania', BO: 'Bolivia', BQ: 'Bonaire, San Eustaquio y Saba', - BR: 'Brazil', - BS: 'Bahamas', - BT: 'Bhután', + BA: 'Bosnia y Herzegovina', BW: 'Botsuana', - BY: 'Bielorrusia', - BZ: 'Belice', + BR: 'Brazil', + BN: 'Brunéi', + BG: 'Bulgaria', + BF: 'Burkina Faso', + BI: 'Burundi', + CV: 'Cabo Verde', + KH: 'Camboya', + CM: 'Camerún', CA: 'Canadá', - CC: 'Islas Cocos (Keeling)', - CD: 'República Democrática del Congo', - CF: 'República Centroafricana', - CG: 'República del Congo', - CH: 'Suiza', - CI: 'Costa de Marfil', - CK: 'Islas Cook', + TD: 'Chad', CL: 'Chile', - CM: 'Camerún', CN: 'China', + CY: 'Chipre', + VA: 'Ciudad del Vaticano', CO: 'Colombia', + KM: 'Comoras', + KP: 'Corea del Norte', + KR: 'Corea del Sur', + CI: 'Costa de Marfil', CR: 'Costa Rica', + HR: 'Croacia', CU: 'Cuba', - CV: 'Cabo Verde', CW: 'Curazao', - CX: 'Isla de Navidad', - CY: 'Chipre', - CZ: 'República Checa', - DE: 'Alemania', - DG: 'Diego García', - DJ: 'Yibuti', DK: 'Dinamarca', DM: 'Dominica', - DO: 'República Dominicana', - DZ: 'Argelia', - EA: 'Ceuta y Melilla', EC: 'Ecuador', - EE: 'Estonia', EG: 'Egipto', - EH: 'Sahara Occidental', + SV: 'El Salvador', + AE: 'Emiratos Árabes Unidos', ER: 'Eritrea', + SK: 'Eslovaquia', + SI: 'Eslovenia', ES: 'España', + US: 'Estados Unidos de América', + EE: 'Estonia', ET: 'Etiopía', - EZ: 'Eurozona', + PH: 'Filipinas', FI: 'Finlandia', FJ: 'Fiyi', - FK: 'Islas Malvinas', - FM: 'Micronesia', - FO: 'Islas Feroe', FR: 'Francia', GA: 'Gabón', - GB: 'Reino Unido', - GD: 'Granada', + GM: 'Gambia', GE: 'Georgia', - GF: 'Guayana Francesa', - GG: 'Guernsey', GH: 'Ghana', GI: 'Gibraltar', + GD: 'Granada', + GR: 'Greece', GL: 'Groenlandia', - GM: 'Gambia', - GN: 'Guinea', GP: 'Guadeloupe', - GQ: 'Guinea Ecuatorial', - GR: 'Greece', - GS: 'Islas Georgias del Sur y Sandwich del Sur', - GT: 'Guatemala', GU: 'Guam', + GT: 'Guatemala', + GF: 'Guayana Francesa', + GG: 'Guernsey', + GN: 'Guinea', + GQ: 'Guinea Ecuatorial', GW: 'Guinea-Bissau', GY: 'Guyana', - HK: 'Hong Kong', - HN: 'Honduras', - HR: 'Croacia', HT: 'Haiti', + HN: 'Honduras', + HK: 'Hong Kong', HU: 'Hungría', - IC: 'Islas Canarias', - ID: 'Indonesia', - IE: 'Irlanda', - IL: 'Israel', - IM: 'Isla de Man', IN: 'India', - IO: 'Territorio Británico del Océano Índico', + ID: 'Indonesia', IQ: 'Irak', IR: 'Irán', + IE: 'Irlanda', + AC: 'Isla Ascensión', + IM: 'Isla de Man', + CX: 'Isla de Navidad', + NF: 'Isla Norfolk', IS: 'Islandia', + BM: 'Islas Bermudas', + KY: 'Islas Caimán', + CC: 'Islas Cocos (Keeling)', + CK: 'Islas Cook', + AX: 'Islas de Åland', + FO: 'Islas Feroe', + GS: 'Islas Georgias del Sur y Sandwich del Sur', + MV: 'Islas Maldivas', + FK: 'Islas Malvinas', + MP: 'Islas Marianas del Norte', + MH: 'Islas Marshall', + PN: 'Islas Pitcairn', + SB: 'Islas Salomón', + TC: 'Islas Turcas y Caicos', + UM: 'Islas Ultramarinas Menores de Estados Unidos', + VG: 'Islas Vírgenes Británicas', + VI: 'Islas Vírgenes de los Estados Unidos', + IL: 'Israel', IT: 'Italia', - JE: 'Jersey', JM: 'Jamaica', - JO: 'Jordania', JP: 'Japón', + JE: 'Jersey', + JO: 'Jordania', + KZ: 'Kazajistán', KE: 'Kenia', KG: 'Kirguistán', - KH: 'Camboya', KI: 'Kiribati', - KM: 'Comoras', - KN: 'San Cristóbal y Nieves', - KP: 'Corea del Norte', - KR: 'Corea del Sur', + XK: 'Kosovo', KW: 'Kuwait', - KY: 'Islas Caimán', - KZ: 'Kazajistán', LA: 'Laos', + LS: 'Lesoto', + LV: 'Letonia', LB: 'Líbano', - LC: 'Santa Lucía', - LI: 'Liechtenstein', - LK: 'Sri Lanka', LR: 'Liberia', - LS: 'Lesoto', + LY: 'Libia', + LI: 'Liechtenstein', LT: 'Lituania', LU: 'Luxemburgo', - LV: 'Letonia', - LY: 'Libia', - MA: 'Marruecos', - MC: 'Mónaco', - MD: 'Moldavia', - ME: 'Montenegro', - MF: 'San Martín (Francia)', - MG: 'Madagascar', - MH: 'Islas Marshall', + MO: 'Macao', MK: 'Macedônia', + MG: 'Madagascar', + MY: 'Malasia', + MW: 'Malawi', ML: 'Mali', - MM: 'Birmania', - MN: 'Mongolia', - MO: 'Macao', - MP: 'Islas Marianas del Norte', + MT: 'Malta', + MA: 'Marruecos', MQ: 'Martinica', MR: 'Mauritania', - MS: 'Montserrat', - MT: 'Malta', MU: 'Mauritius', - MV: 'Islas Maldivas', - MW: 'Malawi', + YT: 'Mayotte', MX: 'México', - MY: 'Malasia', + FM: 'Micronesia', + MD: 'Moldavia', + MC: 'Mónaco', + MN: 'Mongolia', + ME: 'Montenegro', + MS: 'Montserrat', MZ: 'Mozambique', NA: 'Namibia', - NC: 'Nueva Caledonia', + NR: 'Nauru', + NP: 'Nepal', + NI: 'Nicaragua', NE: 'Niger', - NF: 'Isla Norfolk', NG: 'Nigeria', - NI: 'Nicaragua', - NL: 'Países Bajos', - NO: 'Noruega', - NP: 'Nepal', - NR: 'Nauru', NU: 'Niue', + NO: 'Noruega', + NC: 'Nueva Caledonia', NZ: 'Nueva Zealand', OM: 'Omán', + NL: 'Países Bajos', + PK: 'Pakistán', + PW: 'Palau', + PS: 'Palestina', PA: 'Panamá', + PG: 'Papúa Nueva Guinea', + PY: 'Paraguay', PE: 'Perú', PF: 'Polinesia Francesa', - PG: 'Papúa Nueva Guinea', - PH: 'Filipinas', - PK: 'Pakistán', PL: 'Polonia', - PM: 'San Pedro y Miquelón', - PN: 'Islas Pitcairn', - PR: 'Puerto Rico', - PS: 'Palestina', PT: 'Portugal', - PW: 'Palau', - PY: 'Paraguay', + PR: 'Puerto Rico', QA: 'Qatar', + GB: 'Reino Unido', + CF: 'República Centroafricana', + CZ: 'República Checa', + SS: 'República de Sudán del Sur', + CG: 'República del Congo', + CD: 'República Democrática del Congo', + DO: 'República Dominicana', RE: 'Reunión', + RW: 'Ruanda', RO: 'Rumanía', - RS: 'Serbia', RU: 'Rusia', - RW: 'Ruanda', - SA: 'Arabia Saudita', - SB: 'Islas Salomón', - SC: 'Seychelles', - SD: 'Sudán', - SE: 'Suecia', - SG: 'Singapur', - SH: 'Santa Elena', - SI: 'Eslovenia', - SJ: 'Svalbard y Jan Mayen', - SK: 'Eslovaquia', - SL: 'Sierra Leona', + EH: 'Sahara Occidental', + WS: 'Samoa', + AS: 'Samoa Americana', + BL: 'San Bartolomé', + KN: 'San Cristóbal y Nieves', SM: 'San Marino', - SN: 'Senegal', - SO: 'Somalia', - SR: 'Surinám', - SS: 'República de Sudán del Sur', + MF: 'San Martín (Francia)', + PM: 'San Pedro y Miquelón', + VC: 'San Vicente y las Granadinas', + SH: 'Santa Elena', + LC: 'Santa Lucía', ST: 'Santo Tomé y Príncipe', - SV: 'El Salvador', + SN: 'Senegal', + RS: 'Serbia', + SC: 'Seychelles', + SL: 'Sierra Leona', + SG: 'Singapur', SX: 'Sint Maarten', SY: 'Siria', + SO: 'Somalia', + LK: 'Sri Lanka', + ZA: 'Sudáfrica', + SD: 'Sudán', + SE: 'Suecia', + CH: 'Suiza', + SR: 'Surinám', + SJ: 'Svalbard y Jan Mayen', SZ: 'Swazilandia', - TA: 'Tristán de Acuña', - TC: 'Islas Turcas y Caicos', - TD: 'Chad', - TF: 'Territorios Australes y Antárticas Franceses', - TG: 'Togo', TH: 'Tailandia', + TW: 'Taiwán', + TZ: 'Tanzania', TJ: 'Tayikistán', - TK: 'Tokelau', + IO: 'Territorio Británico del Océano Índico', + TF: 'Territorios Australes y Antárticas Franceses', TL: 'Timor Oriental', - TM: 'Turkmenistán', - TN: 'Tunez', + TG: 'Togo', + TK: 'Tokelau', TO: 'Tonga', - TR: 'Turquía', TT: 'Trinidad y Tobago', + TA: 'Tristán de Acuña', + TN: 'Tunez', + TM: 'Turkmenistán', + TR: 'Turquía', TV: 'Tuvalu', - TW: 'Taiwán', - TZ: 'Tanzania', UA: 'Ucrania', UG: 'Uganda', - UM: 'Islas Ultramarinas Menores de Estados Unidos', - UN: 'Naciones Unidas', - US: 'Estados Unidos de América', UY: 'Uruguay', UZ: 'Uzbekistan', - VA: 'Ciudad del Vaticano', - VC: 'San Vicente y las Granadinas', + VU: 'Vanuatu', VE: 'Venezuela', - VG: 'Islas Vírgenes Británicas', - VI: 'Islas Vírgenes de los Estados Unidos', VN: 'Vietnam', - VU: 'Vanuatu', WF: 'Wallis y Futuna', - WS: 'Samoa', - XK: 'Kosovo', YE: 'Yemen', - YT: 'Mayotte', - ZA: 'Sudáfrica', + DJ: 'Yibuti', ZM: 'Zambia', ZW: 'Zimbabue', }, diff --git a/src/pages/settings/Profile/PersonalDetails/AddressPage.js b/src/pages/settings/Profile/PersonalDetails/AddressPage.js index 9702e0aeb986..b594cd09f3a1 100644 --- a/src/pages/settings/Profile/PersonalDetails/AddressPage.js +++ b/src/pages/settings/Profile/PersonalDetails/AddressPage.js @@ -16,6 +16,7 @@ import TextInput from '../../../../components/TextInput'; import styles from '../../../../styles/styles'; import Navigation from '../../../../libs/Navigation/Navigation'; import * as PersonalDetails from '../../../../libs/actions/PersonalDetails'; +import * as ValidationUtils from '../../../../libs/ValidationUtils'; import compose from '../../../../libs/compose'; import AddressSearch from '../../../../components/AddressSearch'; import CountryPicker from '../../../../components/CountryPicker'; @@ -60,8 +61,10 @@ class AddressPage extends Component { this.onCountryUpdate = this.onCountryUpdate.bind(this); const currentCountry = lodashGet(props.privatePersonalDetails, 'address.country') || ''; + const zipSampleFormat = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, [currentCountry, 'samples'], ''); this.state = { isUsaForm: (currentCountry === CONST.COUNTRY.US || currentCountry === CONST.USA_COUNTRY_NAME), + zipFormat: this.props.translate('common.format', {zipSampleFormat}), }; } @@ -69,7 +72,11 @@ class AddressPage extends Component { * @param {String} newCountry - new country selected in form */ onCountryUpdate(newCountry) { - this.setState({isUsaForm: newCountry === CONST.COUNTRY.US}); + const zipSampleFormat = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, `${newCountry}.samples`, ''); + this.setState({ + isUsaForm: newCountry === CONST.COUNTRY.US, + zipFormat: this.props.translate('common.format', {zipSampleFormat}), + }); } /** @@ -82,7 +89,7 @@ class AddressPage extends Component { values.addressLine2.trim(), values.city.trim(), values.state.trim(), - values.zipPostCode, + values.zipPostCode.trim(), values.country, ); } @@ -97,7 +104,6 @@ class AddressPage extends Component { const requiredFields = [ 'addressLine1', 'city', - 'zipPostCode', 'country', 'state', ]; @@ -109,12 +115,31 @@ class AddressPage extends Component { // Add "Field required" errors if any required field is empty _.each(requiredFields, (fieldKey) => { - if (!_.isEmpty(values[fieldKey])) { + if (ValidationUtils.isRequiredFulfilled(values[fieldKey])) { return; } errors[fieldKey] = this.props.translate('common.error.fieldRequired'); }); + // If no country is selected, default value is an empty string and there's no related regex data so we default to an empty object + const countryRegexDetails = lodashGet(CONST.COUNTRY_ZIP_REGEX_DATA, values.country, {}); + + // The postal code system might not exist for a country, so no regex either for them. + const countrySpecificZipRegex = lodashGet(countryRegexDetails, 'regex'); + const zipFormat = lodashGet(countryRegexDetails, 'samples'); + + if (countrySpecificZipRegex) { + if (!countrySpecificZipRegex.test(values.zipPostCode.trim())) { + if (ValidationUtils.isRequiredFulfilled(values.zipPostCode.trim())) { + errors.zipPostCode = this.props.translate('privatePersonalDetails.error.incorrectZipFormat', {zipFormat}); + } else { + errors.zipPostCode = this.props.translate('common.error.fieldRequired'); + } + } + } else if (!CONST.GENERIC_ZIP_CODE_REGEX.test(values.zipPostCode.trim())) { + errors.zipPostCode = this.props.translate('privatePersonalDetails.error.incorrectZipFormat'); + } + return errors; } @@ -170,31 +195,30 @@ class AddressPage extends Component { maxLength={CONST.FORM_CHARACTER_LIMIT} /> - - - {this.state.isUsaForm ? ( - - ) : ( - - )} - - + + {this.state.isUsaForm ? ( + + ) : ( - + )} + + +