Skip to content

Commit

Permalink
account for expandable checklists in validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Dec 5, 2024
1 parent 8b284ed commit 12496de
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ export const ChecklistComponent: React.FC<ChecklistProps> = (props) => {
alert(JSON.stringify({ type, ...values, options }, null, 2));
}
},
validate: ({ options, ...values }) => {
validate: ({ options, groupedOptions, ...values }) => {
const errors: FormikErrors<FormikValues> = {};
// Account for flat or expandable Checklist options
options =
options || groupedOptions?.map((group) => group.children)?.flat();
if (values.fn && !options?.some((option) => option.data.val)) {
errors.fn =
"At least one option must set a data value when the checklist has a data field";
Expand Down

0 comments on commit 12496de

Please sign in to comment.