-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add better error message for picklist
- Loading branch information
1 parent
9dd66f9
commit fdbc4f8
Showing
1 changed file
with
15 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { getPicklistValues } from './data-loaders'; | ||
|
||
export const pickListValidation = (field, name) => (value, helper) => { | ||
const pickList = getPicklistValues(); | ||
|
||
if (pickList[field].includes(value)) { | ||
return value; | ||
} | ||
|
||
return helper.message( | ||
`${name || field} does not include a valid option ${pickList[field].join( | ||
', ', | ||
)}`, | ||
); | ||
}; | ||
import { getPicklistValues } from './data-loaders'; | ||
|
||
export const pickListValidation = (field, name) => (value, helper) => { | ||
const pickList = getPicklistValues(); | ||
|
||
if (pickList[field].includes(value)) { | ||
return value; | ||
} | ||
|
||
return helper.message( | ||
`${name || field} does not include a valid option ${pickList[field].join( | ||
', ', | ||
)} instead got '${value}'`, | ||
); | ||
}; |