Skip to content

Instantly share code, notes, and snippets.

@aerinkim
Last active February 18, 2022 01:02
Show Gist options
  • Save aerinkim/d35904be4387471c295407bf67ea4746 to your computer and use it in GitHub Desktop.
Save aerinkim/d35904be4387471c295407bf67ea4746 to your computer and use it in GitHub Desktop.
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