From 2e497752ea39f634b1ca14eddf27fea4493215e3 Mon Sep 17 00:00:00 2001 From: RgnDunes Date: Fri, 26 Jul 2024 02:55:15 +0530 Subject: [PATCH] resolve review comments --- .../i18nify-js/src/modules/currency/convertToMajorUnit.ts | 2 +- .../i18nify-js/src/modules/currency/convertToMinorUnit.ts | 2 +- packages/i18nify-js/src/modules/currency/getCurrencySymbol.ts | 2 +- packages/i18nify-js/src/modules/dateTime/getWeekdays.ts | 1 - .../i18nify-js/src/modules/geo/__tests__/getCities.test.ts | 2 +- .../i18nify-js/src/modules/geo/__tests__/getStates.test.ts | 2 +- .../i18nify-js/src/modules/geo/__tests__/getZipcodes.test.ts | 2 +- packages/i18nify-js/src/modules/geo/getCities.ts | 2 +- packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts | 2 +- packages/i18nify-js/src/modules/geo/getStates.ts | 2 +- packages/i18nify-js/src/modules/geo/getZipcodes.ts | 2 +- .../phoneNumber/__tests__/getDialCodeByCountryCode.test.ts | 2 +- .../src/modules/phoneNumber/getDialCodeByCountryCode.ts | 2 +- .../src/modules/phoneNumber/getMaskedPhoneNumber.ts | 4 ++-- 14 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/i18nify-js/src/modules/currency/convertToMajorUnit.ts b/packages/i18nify-js/src/modules/currency/convertToMajorUnit.ts index 60528cf8..6a462d0b 100644 --- a/packages/i18nify-js/src/modules/currency/convertToMajorUnit.ts +++ b/packages/i18nify-js/src/modules/currency/convertToMajorUnit.ts @@ -24,7 +24,7 @@ const convertToMajorUnit = ( if (!options.currency || !currencyInfo) { throw new Error( - `The provided currency code is either empty or not supported. The received value was ${(options.currency as any) === '' ? 'an empty string' : `: ${String(options.currency)}`}. Please ensure you pass a valid currency code.`, + `The provided currency code is either empty or not supported. The received value was ${(options.currency as any) === '' ? 'an empty string' : `: ${String(options.currency)}`}. Please ensure you pass a valid currency code. Check valid currency codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/currency/data.json`, ); } diff --git a/packages/i18nify-js/src/modules/currency/convertToMinorUnit.ts b/packages/i18nify-js/src/modules/currency/convertToMinorUnit.ts index 364d07af..39765438 100644 --- a/packages/i18nify-js/src/modules/currency/convertToMinorUnit.ts +++ b/packages/i18nify-js/src/modules/currency/convertToMinorUnit.ts @@ -24,7 +24,7 @@ const convertToMinorUnit = ( if (!options.currency || !currencyInfo) { throw new Error( - `The provided currency code is either empty or not supported. The received value was ${(options.currency as any) === '' ? 'an empty string' : `: ${String(options.currency)}`}. Please ensure you pass a valid currency code.`, + `The provided currency code is either empty or not supported. The received value was ${(options.currency as any) === '' ? 'an empty string' : `: ${String(options.currency)}`}. Please ensure you pass a valid currency code. Check valid currency codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/currency/data.json`, ); } diff --git a/packages/i18nify-js/src/modules/currency/getCurrencySymbol.ts b/packages/i18nify-js/src/modules/currency/getCurrencySymbol.ts index c7f5ba78..999cbf89 100644 --- a/packages/i18nify-js/src/modules/currency/getCurrencySymbol.ts +++ b/packages/i18nify-js/src/modules/currency/getCurrencySymbol.ts @@ -8,7 +8,7 @@ const getCurrencySymbol = (currencyCode: CurrencyCodeType): string => { return currencyInformation[currencyCode]?.symbol; else throw new Error( - `The provided currency code is invalid. The received value was: ${String(currencyCode)}. Please ensure you pass a valid currency code.`, + `The provided currency code is invalid. The received value was: ${String(currencyCode)}. Please ensure you pass a valid currency code. Check valid currency codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/currency/data.json`, ); }; diff --git a/packages/i18nify-js/src/modules/dateTime/getWeekdays.ts b/packages/i18nify-js/src/modules/dateTime/getWeekdays.ts index 54d69cf0..f106cfec 100644 --- a/packages/i18nify-js/src/modules/dateTime/getWeekdays.ts +++ b/packages/i18nify-js/src/modules/dateTime/getWeekdays.ts @@ -14,7 +14,6 @@ const getWeekdays = (options: { locale?: Locale; weekday?: 'long' | 'short' | 'narrow' | undefined; }): string[] => { - console.log({ options }); try { const locale = getLocale(options); diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getCities.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getCities.test.ts index ad468604..47564666 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getCities.test.ts +++ b/packages/i18nify-js/src/modules/geo/__tests__/getCities.test.ts @@ -31,7 +31,7 @@ describe('getCities', () => { // @ts-expect-error invalid country code for testing await expect(getCities(invalidCountryCode)).rejects.toEqual( new Error( - `Invalid country code: XYZ. Please ensure you provide a valid country code.`, + `Invalid country code: XYZ. Please ensure you provide a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ), ); }); diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getStates.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getStates.test.ts index ea820f2b..e1a11e19 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getStates.test.ts +++ b/packages/i18nify-js/src/modules/geo/__tests__/getStates.test.ts @@ -22,7 +22,7 @@ describe('getStates', () => { // @ts-expect-error invalid state code for testing await expect(() => getStates('XYZ')).rejects.toEqual( new Error( - `Invalid country code: XYZ. Please ensure you provide a valid country code.`, + `Invalid country code: XYZ. Please ensure you provide a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ), ); }); diff --git a/packages/i18nify-js/src/modules/geo/__tests__/getZipcodes.test.ts b/packages/i18nify-js/src/modules/geo/__tests__/getZipcodes.test.ts index 14df2d5a..da7d01d9 100644 --- a/packages/i18nify-js/src/modules/geo/__tests__/getZipcodes.test.ts +++ b/packages/i18nify-js/src/modules/geo/__tests__/getZipcodes.test.ts @@ -54,7 +54,7 @@ describe('getZipcodes', () => { await expect( getZipcodes(validCountryCode, missingStateCode), ).rejects.toThrow( - `An error occurred while fetching zipcode data. The error details are: State code ${missingStateCode} is missing in ${validCountryCode}. Please ensure you provide a valid state code that exists within the specified country..`, + `An error occurred while fetching zipcode data. The error details are: State code ${missingStateCode} is missing in ${validCountryCode}. Please ensure you provide a valid state code that exists within the specified country. Check valid state codes and country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json.`, ); }); diff --git a/packages/i18nify-js/src/modules/geo/getCities.ts b/packages/i18nify-js/src/modules/geo/getCities.ts index 69d23d43..c204d1f8 100644 --- a/packages/i18nify-js/src/modules/geo/getCities.ts +++ b/packages/i18nify-js/src/modules/geo/getCities.ts @@ -23,7 +23,7 @@ const getCities = ( if (!I18NIFY_DATA_SUPPORTED_COUNTRIES.includes(countryCode)) { return Promise.reject( new Error( - `Invalid country code: ${countryCode}. Please ensure you provide a valid country code.`, + `Invalid country code: ${countryCode}. Please ensure you provide a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ), ); } diff --git a/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts b/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts index a3273b1e..af642f3a 100644 --- a/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts +++ b/packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts @@ -18,7 +18,7 @@ import { isCountryValid } from './utils'; const getFlagOfCountry = (_countryCode: CountryCodeType): GetFlagReturnType => { if (!isCountryValid(_countryCode)) { throw new Error( - `The provided country code is invalid. The received value was: ${_countryCode}. Please ensure you pass a valid country code.`, + `The provided country code is invalid. The received value was: ${_countryCode}. Please ensure you pass a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ); } diff --git a/packages/i18nify-js/src/modules/geo/getStates.ts b/packages/i18nify-js/src/modules/geo/getStates.ts index 513babd2..a2778e7e 100644 --- a/packages/i18nify-js/src/modules/geo/getStates.ts +++ b/packages/i18nify-js/src/modules/geo/getStates.ts @@ -19,7 +19,7 @@ const getStates = (_countryCode: I18nifyCountryCodeType) => { if (!I18NIFY_DATA_SUPPORTED_COUNTRIES.includes(countryCode)) { return Promise.reject( new Error( - `Invalid country code: ${countryCode}. Please ensure you provide a valid country code.`, + `Invalid country code: ${countryCode}. Please ensure you provide a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ), ); } diff --git a/packages/i18nify-js/src/modules/geo/getZipcodes.ts b/packages/i18nify-js/src/modules/geo/getZipcodes.ts index 75805352..6c770a78 100644 --- a/packages/i18nify-js/src/modules/geo/getZipcodes.ts +++ b/packages/i18nify-js/src/modules/geo/getZipcodes.ts @@ -63,7 +63,7 @@ const getZipcodes = (_countryCode: CountryCodeType, _stateCode?: string) => { if (!res.states[stateCode]) { return Promise.reject( - `State code ${stateCode} is missing in ${countryCode}. Please ensure you provide a valid state code that exists within the specified country.`, + `State code ${stateCode} is missing in ${countryCode}. Please ensure you provide a valid state code that exists within the specified country. Check valid state codes and country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ); } diff --git a/packages/i18nify-js/src/modules/phoneNumber/__tests__/getDialCodeByCountryCode.test.ts b/packages/i18nify-js/src/modules/phoneNumber/__tests__/getDialCodeByCountryCode.test.ts index 4cc84eb1..70f86039 100644 --- a/packages/i18nify-js/src/modules/phoneNumber/__tests__/getDialCodeByCountryCode.test.ts +++ b/packages/i18nify-js/src/modules/phoneNumber/__tests__/getDialCodeByCountryCode.test.ts @@ -21,7 +21,7 @@ describe('phoneNumber - getDialCodeByCountryCode', () => { const invalidCountryCode = 'XX'; // XX is not a valid country code expect(() => getDialCodeByCountryCode(invalidCountryCode as any)).toThrow( new Error( - `Error: The provided country code is invalid. The received value was: ${invalidCountryCode}. Please ensure you pass a valid country code.`, + `Error: The provided country code is invalid. The received value was: ${invalidCountryCode}. Please ensure you pass a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ), ); }); diff --git a/packages/i18nify-js/src/modules/phoneNumber/getDialCodeByCountryCode.ts b/packages/i18nify-js/src/modules/phoneNumber/getDialCodeByCountryCode.ts index aadd6f18..743b40c2 100644 --- a/packages/i18nify-js/src/modules/phoneNumber/getDialCodeByCountryCode.ts +++ b/packages/i18nify-js/src/modules/phoneNumber/getDialCodeByCountryCode.ts @@ -22,7 +22,7 @@ const getDialCodeByCountryCode = (countryCode: CountryCodeType): string => { return dialCodeForAllCountries[countryCode]; else throw new Error( - `The provided country code is invalid. The received value was: ${countryCode}. Please ensure you pass a valid country code.`, + `The provided country code is invalid. The received value was: ${countryCode}. Please ensure you pass a valid country code. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ); }; diff --git a/packages/i18nify-js/src/modules/phoneNumber/getMaskedPhoneNumber.ts b/packages/i18nify-js/src/modules/phoneNumber/getMaskedPhoneNumber.ts index 5a220b39..f7898cee 100644 --- a/packages/i18nify-js/src/modules/phoneNumber/getMaskedPhoneNumber.ts +++ b/packages/i18nify-js/src/modules/phoneNumber/getMaskedPhoneNumber.ts @@ -38,7 +38,7 @@ const getMaskedPhoneNumber = ({ if (!countryCode && !phoneNumber) { throw new Error( - `Either 'countryCode' or 'phoneNumber' is mandatory. Please provide a valid 'countryCode' or 'phoneNumber'.`, + `Either 'countryCode' or 'phoneNumber' is mandatory. Please provide a valid 'countryCode' or 'phoneNumber'. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ); } @@ -100,7 +100,7 @@ const getMaskedPhoneNumber = ({ maskedContactNumber = PHONE_FORMATTER_MAPPER[countryCode]; if (!maskedContactNumber) { throw new Error( - `Parameter 'countryCode' is invalid. The received value was: ${countryCode}.`, + `Parameter 'countryCode' is invalid. The received value was: ${countryCode}. Check valid country codes here: https://github.com/razorpay/i18nify/blob/master/i18nify-data/country/metadata/data.json`, ); } dialCode = getDialCodeByCountryCode(countryCode);