Last active
February 17, 2022 23:24
-
-
Save aerinkim/23b0820410a2208119fe74927a4d60be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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