-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[$125] Error message displayed when adding a UK zip code to a GBP payment card #52642
Comments
Triggered auto assignment to @sakluger ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Adding a UK zip code to a GBP payment card errors out incorrectly What is the root cause of that problem?We only check valid zip code and not check valid us post code App/src/components/AddPaymentCard/PaymentCardForm.tsx Lines 168 to 170 in 1b9e302
What changes do you think we should make in order to solve the problem?
Notes: we should add What alternative solutions did you explore? (Optional)Simply we only need to update |
This seems like a pretty easy change. I'm going to set the initial price at $125. If this needs to be done for several countries, and each one requires specific treatment, then we can consider a higher price, but it doesn't seem like that's necessary for now. |
Job added to Upwork: https://www.upwork.com/jobs/~021857542773027117579 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha ( |
Upwork job price has been updated to $125 |
ProposalPlease re-state the problem that we are trying to solve in this issueError message displayed when adding a UK zip code to a GBP payment card. What is the root cause of that problem?The current App/src/components/AddPaymentCard/PaymentCardForm.tsx Lines 168 to 170 in 99bf554
What changes do you think we should make in order to solve the problem?Adjust the validate logic similarly to what we do in Address / AddressForm which is Zip Code validation based on the selected country, in our case for a more comprehensive solution we'll validate Zip Code based on selected Currency. To do this we will add / adjust the following:
/**
* Get the country code for a certain currency(ISO 4217) Code
*/
function getCurrencyCountryCodes(currencyCode: keyof typeof CONST.CURRENCY): Array<keyof typeof CONST.ALL_COUNTRIES> {
const currencyCountryMap: Record<keyof typeof CONST.CURRENCY, Array<keyof typeof CONST.ALL_COUNTRIES>> = {
[CONST.CURRENCY.USD]: ['US'],
[CONST.CURRENCY.AUD]: ['AU'],
[CONST.CURRENCY.CAD]: ['CA'],
[CONST.CURRENCY.GBP]: ['GB'],
[CONST.CURRENCY.NZD]: ['NZ'],
[CONST.CURRENCY.EUR]: ['AT', 'BE', 'CY', 'EE', 'FI', 'FR', 'DE', 'GR', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PT', 'SK', 'SI', 'ES'],
};
return currencyCountryMap[currencyCode] ?? [];
}
// Use provided currency or default to USD
const currency = data?.currency ?? CONST.PAYMENT_CARD_CURRENCY.USD;
// Get countries associated with the currency
const countries = CurrencyUtils.getCurrencyCountryCodes(currency);
// Check if the addressZipCode matches any country-specific regex
if (values.addressZipCode) {
const zipCode = values.addressZipCode.trim();
const isValidZip = countries.some((countryCode) => {
const regexDetails = CONST.COUNTRY_ZIP_REGEX_DATA[countryCode];
// Optionally: check for empty string after trim
if (!zipCode) {
return false;
}
return 'regex' in regexDetails && regexDetails.regex.test(zipCode);
});
if (!isValidZip) {
errors.addressZipCode = translate(label.error.addressZipCode);
}
} this will ensure that the Zip Code is validated based on the currency selected in the Add payment card, defaulting to USD just like the Currency field. Here's a test branch: ikevin127-cardZipCodeValidation for testing convenience or the diff if preferred. Result video (before / after)MacOS: Chrome
|
@sakluger In the proposed solution I made sure to include logic for each specific currency / country and also for the I'd say that justifies the base $250 bounty for this issue in case the proposed solution will be the one selected. Thank you! |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.63-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @muttmuure
Slack conversation (hyperlinked to channel name): ts_external_expensify_bugs
Action Performed:
Expected Result:
A UK post code is accepted
Actual Result:
The Zip Code field shows an error.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @getushaThe text was updated successfully, but these errors were encountered: