Skip to content

Instantly share code, notes, and snippets.

@aerinkim
Last active February 17, 2022 23:52
Show Gist options
  • Save aerinkim/18b71ae4a78920192bea796b9cc0de02 to your computer and use it in GitHub Desktop.
Save aerinkim/18b71ae4a78920192bea796b9cc0de02 to your computer and use it in GitHub Desktop.
export function lint(response) {
const lintIssues = [];
let isLabelable = true;
if (response.values) {
for (const value of response.values) {
if (value.field_id === 'invoice_labeling' && !value.selected.includes('yes')) {
isLabelable = false;
}
}
if (isLabelable) {
if (response.annotations) {
if (!response.annotations.some(annotation => annotation.label === 'Vendor name') ||
!response.annotations.some(annotation => annotation.label === 'Invoice Amount Due')) {
lintIssues.push({
id: 'invoice_labeling',
display: 'Invoice must have Invoice Amount Due and Vendor Name labels.',
blocksSubmission: true,
});
}
}
}
}
return {
lintIssues,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment