Skip to content

Instantly share code, notes, and snippets.

@aerinkim
Last active February 17, 2022 23:24
Show Gist options
  • Save aerinkim/23b0820410a2208119fe74927a4d60be to your computer and use it in GitHub Desktop.
Save aerinkim/23b0820410a2208119fe74927a4d60be to your computer and use it in GitHub Desktop.
const REGEX_ISO_CURRENCY_CODE = /[A-Z]{3}/;
const labelsToCheck = ['Invoice Total', 'Invoice Amount Due', 'Item Amount', 'Unit Price'];
export function lint(response) {
const lintIssues = [];
if (response.annotations) {
for (const annotation of response.annotations) {
if (labelsToCheck.includes(annotation.label)) {
if (REGEX_ISO_CURRENCY_CODE.test(annotation.text)) {
lintIssues.push({
id: annotation.uuid,
label: annotation.label,
frame: annotation.page,
display:
'Money amounts should not include 3-letter currency codes. Please double check.',
});
}
}
}
}
return {
lintIssues,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment