@@ -290,21 +290,29 @@ export const AppCommandSchema = z.discriminatedUnion("name", [
290290 "Group name; an existing group with this name is returned instead of a duplicate." ,
291291 ) ,
292292 } ) ,
293- z . strictObject ( {
294- name : z . literal ( "create_contact" ) ,
295- givenName : z . string ( ) . max ( 1024 ) . optional ( ) ,
296- familyName : z . string ( ) . max ( 1024 ) . optional ( ) ,
297- organization : z . string ( ) . max ( 1024 ) . optional ( ) ,
298- jobTitle : z . string ( ) . max ( 1024 ) . optional ( ) ,
299- emails : z . array ( z . string ( ) . min ( 3 ) . max ( 320 ) ) . max ( 5 ) . optional ( ) ,
300- phones : z . array ( z . string ( ) . min ( 1 ) . max ( 64 ) ) . max ( 5 ) . optional ( ) ,
301- groupId : z
302- . string ( )
303- . min ( 1 )
304- . max ( 256 )
305- . optional ( )
306- . describe ( "An id from list_contact_groups or create_contact_group." ) ,
307- } ) ,
293+ z
294+ . strictObject ( {
295+ name : z . literal ( "create_contact" ) ,
296+ givenName : z . string ( ) . max ( 1024 ) . optional ( ) ,
297+ familyName : z . string ( ) . max ( 1024 ) . optional ( ) ,
298+ organization : z . string ( ) . max ( 1024 ) . optional ( ) ,
299+ jobTitle : z . string ( ) . max ( 1024 ) . optional ( ) ,
300+ emails : z . array ( z . string ( ) . min ( 3 ) . max ( 320 ) ) . max ( 5 ) . optional ( ) ,
301+ phones : z . array ( z . string ( ) . min ( 1 ) . max ( 64 ) ) . max ( 5 ) . optional ( ) ,
302+ groupId : z
303+ . string ( )
304+ . min ( 1 )
305+ . max ( 256 )
306+ . optional ( )
307+ . describe ( "An id from list_contact_groups or create_contact_group." ) ,
308+ } )
309+ . refine (
310+ ( contact ) =>
311+ Boolean ( contact . givenName ?. trim ( ) || contact . familyName ?. trim ( ) || contact . organization ?. trim ( ) ) ,
312+ {
313+ message : "A contact needs a name or an organization" ,
314+ } ,
315+ ) ,
308316] ) ;
309317export type AppCommand = z . infer < typeof AppCommandSchema > ;
310318
0 commit comments