frontend/.pnpm-store/v3/files/f2/f8c865165855867fd43b5c38e2cc4284ec8eed5af6d052e54bab643c4e24848e2691d0b2ec8811a30276c973e2920e0b4501b86de4a87bdd3ae1086bebb295-exec

22 lines
564 B
Plaintext
Executable File

/**
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
* @param str string to convert
*/
function toUpperCase(str) {
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
}
var NOT_A_Z_REGEX = /[^A-Z]/;
/**
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
*/
export function IsWellFormedCurrencyCode(currency) {
currency = toUpperCase(currency);
if (currency.length !== 3) {
return false;
}
if (NOT_A_Z_REGEX.test(currency)) {
return false;
}
return true;
}