Skip to content

Commit 4c48241

Browse files
committed
add eligibility check to children card fields in order to throw more meaningful error messages when card fields aren't eligible
1 parent c24510b commit 4c48241

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/zoid/card-fields/component.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ export const getCardFieldsComponent: () => CardFieldsComponent = memoize(
216216
},
217217
},
218218

219+
eligible: ({ props }) => {
220+
// Prevent child field from being eligible if parent is not eligible
221+
// Parent props will be empty as eligibility is checked before props are set
222+
if (Object.keys(props.parent.props).length === 0) {
223+
return { eligible: false };
224+
}
225+
return { eligible: true };
226+
},
227+
219228
props: {
220229
type: {
221230
type: "string",

0 commit comments

Comments
 (0)