Last active
February 18, 2022 01:02
-
-
Save aerinkim/d35904be4387471c295407bf67ea4746 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_no_dollar_sign = /[!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/; | |
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_no_dollar_sign.test(annotation.text)) { | |
lintIssues.push({ | |
id: annotation.uuid, | |
label: annotation.label, | |
frame: annotation.page, | |
display: | |
'The amount should only contain numbers and dots.', | |
}); | |
} | |
} | |
} | |
} | |
return { | |
lintIssues, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment