Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export const Wiki = z
events: z.array(BaseEvents).nullish(),
user: z.object({ id: z.string() }),
author: z.object({ id: z.string() }),
operator: z.object({ id: z.string() }).optional(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The structure z.object({ id: z.string() }) is now duplicated across user, author, and the newly added operator fields. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, I suggest creating a reusable schema for this structure.

You could define a new schema in the 'Supporting Schemas' section, similar to other base types in this file:

export const UserReference = z.object({ id: z.string() });

Then, you can use it for user, author, and operator fields like so:

user: UserReference,
author: UserReference,
operator: UserReference.optional(),

This will make the Wiki schema cleaner and easier to manage if the user reference structure ever needs to be changed.

language: LanguagesISO.default(LanguagesISO.Enum.en),
version: z.number().default(1),
linkedWikis: z
Expand Down