MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_validate_nested_object

Function test_validate_nested_object

core/src/llm/structured_tests.rs:364–384  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

362
363#[test]
364fn test_validate_nested_object() {
365 let schema = serde_json::json!({
366 "type": "object",
367 "required": ["user"],
368 "properties": {
369 "user": {
370 "type": "object",
371 "required": ["email"],
372 "properties": {
373 "email": {"type": "string"}
374 }
375 }
376 }
377 });
378 let good = serde_json::json!({"user": {"email": "a@b.com"}});
379 assert!(validate_against_schema(&good, &schema).is_ok());
380
381 let bad = serde_json::json!({"user": {}});
382 let errors = validate_against_schema(&bad, &schema).unwrap_err();
383 assert!(errors.iter().any(|e| e.contains("email")));
384}
385
386// ========================================================================
387// generate_blocking tests

Callers

nothing calls this directly

Calls 1

validate_against_schemaFunction · 0.85

Tested by

no test coverage detected