@@ -1246,4 +1246,37 @@ describe("missing required field error message", () => {
12461246 const result = analyzeResponse ( JSON . stringify ( { name : "Alice" } ) , schema , "test" , 1 ) ;
12471247 expect ( result . ok ) . toBe ( true ) ;
12481248 } ) ;
1249+
1250+ it ( "reports a missing required array field with type 'array'" , ( ) => {
1251+ const schema = s . object ( { items : s . array ( s . string ) , name : s . string } ) ;
1252+ const result = analyzeResponse ( JSON . stringify ( { name : "x" } ) , schema , "test" , 1 ) ;
1253+ expect ( result . ok ) . toBe ( false ) ;
1254+ if ( ! result . ok ) {
1255+ expect ( result . error . message ) . toContain ( "missing required field" ) ;
1256+ expect ( result . error . message ) . toContain ( "$.items" ) ;
1257+ expect ( result . error . message ) . toContain ( "array" ) ;
1258+ }
1259+ } ) ;
1260+
1261+ it ( "reports a missing required nullable field with '<inner> | null'" , ( ) => {
1262+ const schema = s . object ( { score : s . nullable ( s . number ) , name : s . string } ) ;
1263+ const result = analyzeResponse ( JSON . stringify ( { name : "x" } ) , schema , "test" , 1 ) ;
1264+ expect ( result . ok ) . toBe ( false ) ;
1265+ if ( ! result . ok ) {
1266+ expect ( result . error . message ) . toContain ( "missing required field" ) ;
1267+ expect ( result . error . message ) . toContain ( "$.score" ) ;
1268+ expect ( result . error . message ) . toContain ( "number | null" ) ;
1269+ }
1270+ } ) ;
1271+
1272+ it ( "reports a missing required enum field with enum values" , ( ) => {
1273+ const schema = s . object ( { status : s . enum ( "open" , "closed" ) , name : s . string } ) ;
1274+ const result = analyzeResponse ( JSON . stringify ( { name : "x" } ) , schema , "test" , 1 ) ;
1275+ expect ( result . ok ) . toBe ( false ) ;
1276+ if ( ! result . ok ) {
1277+ expect ( result . error . message ) . toContain ( "missing required field" ) ;
1278+ expect ( result . error . message ) . toContain ( "$.status" ) ;
1279+ expect ( result . error . message ) . toContain ( '"open"' ) ;
1280+ }
1281+ } ) ;
12491282} ) ;
0 commit comments