amaannawab923 commented on code in PR #36416:
URL: https://github.com/apache/superset/pull/36416#discussion_r2665779458
##########
superset-frontend/packages/superset-ui-core/src/currency-format/CurrencyFormatter.ts:
##########
@@ -41,6 +45,38 @@ export const getCurrencySymbol = (currency:
Partial<Currency>) =>
.formatToParts(1)
.find(x => x.type === 'currency')?.value;
+/** Normalize currency to ISO 4217 format (e.g., "USD"). Returns null if
invalid. */
+export function normalizeCurrency(
Review Comment:
we can do a simplified version
const ISO_4217_REGEX = /^[A-Z]{3}$/;
export function normalizeCurrency(
value: string | null | undefined,
): string | null {
if (isUndefined(value) || isNull(value)) return null; lodash checks
const normalized = value.trim().toUpperCase();
return ISO_4217_REGEX.test(normalized) ? normalized : null;
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]