Skip to content

Commit

Permalink
resolve review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RgnDunes committed Jul 25, 2024
1 parent 2aba632 commit 2e49775
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
};

Expand Down
1 change: 0 additions & 1 deletion packages/i18nify-js/src/modules/dateTime/getWeekdays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const getWeekdays = (options: {
locale?: Locale;
weekday?: 'long' | 'short' | 'narrow' | undefined;
}): string[] => {
console.log({ options });
try {
const locale = getLocale(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/i18nify-js/src/modules/geo/getCities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/i18nify-js/src/modules/geo/getFlagOfCountry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/i18nify-js/src/modules/geo/getStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/i18nify-js/src/modules/geo/getZipcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2e49775

Please sign in to comment.