Skip to content

Commit 361cb2c

Browse files
add ability to have string only for contributors
1 parent a9d5298 commit 361cb2c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

contributors/_schema/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ const Roles = z
3333
)
3434
)
3535
.strict();
36-
37-
export const ContributorSchema = ({ image } : SchemaContext) => z.object({
38-
name: z.string(),
39-
avatar: image(),
40-
type: z.enum(["founder", "contractor", "community"]).array(),
41-
roles: Roles,
42-
contacts: SocialsSchema.array()
43-
.default([])
44-
.transform((contacts) => contacts.map(transformSocial)),
45-
});
36+
37+
const TYPE = z.enum(["founder", "contractor", "community"]);
38+
export const ContributorSchema = ({ image }: SchemaContext) =>
39+
z.object({
40+
name: z.string(),
41+
avatar: image(),
42+
type: z.union([TYPE, TYPE.array()]),
43+
roles: Roles,
44+
contacts: SocialsSchema.array()
45+
.default([])
46+
.transform((contacts) => contacts.map(transformSocial)),
47+
});

0 commit comments

Comments
 (0)