Skip to content

Commit 55929f7

Browse files
committed
Optimize schema
1 parent 1f7d29c commit 55929f7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/schemas/common.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ export const booleanSchema = (
128128
const baseSchema = z.boolean().describe(description);
129129

130130
if (defaultValue !== undefined) {
131-
const schemaWithDefault = baseSchema.default(defaultValue);
132-
return optional ? schemaWithDefault.optional() : schemaWithDefault;
131+
return baseSchema.default(defaultValue);
133132
}
134133

135-
return optional ? baseSchema.optional() : baseSchema;
134+
if (optional) {
135+
return baseSchema.optional();
136+
}
137+
138+
return baseSchema;
136139
};
137140

138141
/**

0 commit comments

Comments
 (0)