@@ -197,7 +197,7 @@ export function zRegex<T extends ZodString>(zStr: T) {
197197 } ) ;
198198}
199199
200- export const zEmbedInput = z . object ( {
200+ export const zEmbedInput = z . strictObject ( {
201201 title : z . string ( ) . optional ( ) ,
202202 description : z . string ( ) . optional ( ) ,
203203 url : z . string ( ) . optional ( ) ,
@@ -262,6 +262,8 @@ export const zEmbedInput = z.object({
262262 } ) ,
263263 )
264264 . nullable ( ) ,
265+ } ) . meta ( {
266+ id : "embedInput" ,
265267} ) ;
266268
267269export type EmbedWith < T extends keyof APIEmbed > = APIEmbed & Pick < Required < APIEmbed > , T > ;
@@ -271,15 +273,17 @@ export const zStrictMessageContent = z.strictObject({
271273 tts : z . boolean ( ) . optional ( ) ,
272274 embeds : z . union ( [ z . array ( zEmbedInput ) , zEmbedInput ] ) . optional ( ) ,
273275 embed : zEmbedInput . optional ( ) ,
274- } ) . refine ( ( data ) => {
276+ } ) . transform ( ( data ) => {
275277 if ( data . embed ) {
276278 data . embeds = [ data . embed ] ;
277279 delete data . embed ;
278280 }
279281 if ( data . embeds && ! Array . isArray ( data . embeds ) ) {
280282 data . embeds = [ data . embeds ] ;
281283 }
282- return true ;
284+ return data as StrictMessageContent ;
285+ } ) . meta ( {
286+ id : "strictMessageContent" ,
283287} ) ;
284288
285289export type ZStrictMessageContent = z . infer < typeof zStrictMessageContent > ;
@@ -294,7 +298,7 @@ export type MessageContent = string | StrictMessageContent;
294298export const zMessageContent = z . union ( [
295299 zBoundedCharacters ( 0 , 4000 ) ,
296300 zStrictMessageContent ,
297- ] ) as z . ZodType < MessageContent > ;
301+ ] ) ;
298302
299303export function validateAndParseMessageContent ( input : unknown ) : StrictMessageContent {
300304 if ( input == null ) {
0 commit comments