Skip to content

Commit

Permalink
fix: ensure picklist values are formatted correctly prior to comparis…
Browse files Browse the repository at this point in the history
…on (#3649)

* fix: ensure picklist values are formatted correctly prior to comparison

* fix: adds a cleaner error message

* fix: re-add missing context
  • Loading branch information
as1729 authored Oct 16, 2024
1 parent 9543a07 commit 2722baf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/server/src/arpa_reporter/services/validate-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ async function validateRecord({ upload, record, typeRules: rules }) {
const lcItems = rule.listVals.map((val) => multiselect(val.toLowerCase()));

// for pick lists, the value must be one of possible values
if (rule.dataType === 'Pick List' && !lcItems.includes(value)) {
if (rule.dataType === 'Pick List' && !lcItems.includes(multiselect(value))) {
errors.push(new ValidationError(
`Value for ${key} ('${value}') must be one of ${lcItems.length} options in the input template`,
`Value for ${key} ('${value}') must be one of ${lcItems.length} valid options in the input template. (${JSON.stringify(lcItems)})`,
{ col: rule.columnName, severity: 'err' },
));
}
Expand All @@ -339,7 +339,7 @@ async function validateRecord({ upload, record, typeRules: rules }) {
for (const entry of entries) {
if (!lcItems.includes(entry)) {
errors.push(new ValidationError(
`Entry '${entry}' of ${key} is not one of ${lcItems.length} valid options`,
`Entry '${entry}' of ${key} is not one of ${lcItems.length} valid options (${JSON.stringify(lcItems)})`,
{ col: rule.columnName, severity: 'err' },
));
}
Expand Down

0 comments on commit 2722baf

Please sign in to comment.