Skip to content

Commit 56db146

Browse files
committed
refactor: infer
1 parent 6422bdd commit 56db146

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

  • packages/slice-machine/src/legacy/lib/models/common/widgets/ContentRelationship

packages/slice-machine/src/legacy/lib/models/common/widgets/ContentRelationship/Form.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,26 @@ import WidgetFormField from "@/legacy/lib/builders/common/EditModal/Field";
88
import { createFieldNameFromKey } from "@/legacy/lib/forms";
99
import { DefaultFields } from "@/legacy/lib/forms/defaults";
1010

11+
const customTypesShape = yup.array(
12+
yup.object({
13+
id: yup.string(),
14+
fields: yup.array(yup.string()),
15+
}),
16+
);
17+
1118
const FormFields = {
1219
label: DefaultFields.label,
1320
id: DefaultFields.id,
1421
customtypes: {
15-
validate: () =>
16-
yup.array(
17-
yup.object({
18-
id: yup.string(),
19-
fields: yup.array(yup.string()),
20-
}),
21-
),
22+
validate: () => customTypesShape,
2223
},
2324
};
2425

2526
type FormProps = {
2627
config: {
2728
label: string;
2829
select: string;
29-
customtypes?: { id: string; fields: string[] }[];
30+
customtypes?: yup.InferType<typeof customTypesShape>;
3031
};
3132
id: string;
3233
// TODO: this exists in the yup schema but this doesn't seem to be validated by formik

0 commit comments

Comments
 (0)