Skip to content

Commit 2ae6263

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 2ae6263

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/zoid/card-fields/component.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ 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 {
224+
eligible: false,
225+
reason: "card payments are not eligible",
226+
};
227+
}
228+
return { eligible: true };
229+
},
230+
219231
props: {
220232
type: {
221233
type: "string",

0 commit comments

Comments
 (0)