Closed ossamaweb closed 2 months ago
There are a number of issues and discussions in the Zod repo. I suggest looking for and contributing to those before trying to solve it on this level.
@StefanTerdell Thanks. I saw the feature proposal you have participated in 2548
I don't think it will added soon. Meanwhile I had to implement this hacky solution on my project:
declare module 'zod' {
interface ZodTypeDef {
title?: string;
description?: string;
example?: unknown;
}
interface ZodType {
title(title: string): this;
describe(description: string): this;
example(example: unknown): this;
}
}
// Extend Zod to add describe, title, and example methods
z.ZodType.prototype.describe = function (description?: string | undefined) {
this._def.description = description;
return this;
};
z.ZodType.prototype.title = function (title?: string | undefined) {
this._def.title = title;
return this;
};
z.ZodType.prototype.example = function (example?: unknown | undefined) {
this._def.example = example;
return this;
};
I've actually been considering doing something similar for v4! I think we'll leave v3 as it is for now though.
I've actually been considering doing something similar for v4! I think we'll leave v3 as it is for now though.
Good Luck ;)
Hacky