Last active
February 17, 2022 23:52
-
-
Save aerinkim/18b71ae4a78920192bea796b9cc0de02 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
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