@@ -718,7 +718,8 @@ export function validateAndParseFieldValue(
718718 */
719719export function validateStructuredOutputValues (
720720 signature : Readonly < AxSignature > ,
721- values : Record < string , unknown >
721+ values : Record < string , unknown > ,
722+ options ?: { allowMissingRequired ?: boolean }
722723) : void {
723724 const outputFields = signature . getOutputFields ( ) ;
724725
@@ -727,7 +728,7 @@ export function validateStructuredOutputValues(
727728
728729 // Check required fields
729730 if ( value === undefined || value === null ) {
730- if ( ! field . isOptional ) {
731+ if ( ! field . isOptional && ! options ?. allowMissingRequired ) {
731732 throw createRequiredFieldMissingError ( field ) ;
732733 }
733734 continue ;
@@ -773,7 +774,11 @@ export function validateStructuredOutputValues(
773774 typeof value === 'object' &&
774775 ! Array . isArray ( value )
775776 ) {
776- validateNestedObjectFields ( field , value as Record < string , unknown > ) ;
777+ validateNestedObjectFields (
778+ field ,
779+ value as Record < string , unknown > ,
780+ options
781+ ) ;
777782 }
778783
779784 // Validate array of objects
@@ -785,7 +790,11 @@ export function validateStructuredOutputValues(
785790 ) {
786791 for ( const item of value ) {
787792 if ( item && typeof item === 'object' ) {
788- validateNestedObjectFields ( field , item as Record < string , unknown > ) ;
793+ validateNestedObjectFields (
794+ field ,
795+ item as Record < string , unknown > ,
796+ options
797+ ) ;
789798 }
790799 }
791800 }
@@ -797,7 +806,8 @@ export function validateStructuredOutputValues(
797806 */
798807function validateNestedObjectFields (
799808 parentField : Readonly < AxField > ,
800- obj : Record < string , unknown >
809+ obj : Record < string , unknown > ,
810+ options ?: { allowMissingRequired ?: boolean }
801811) : void {
802812 const fields = parentField . type ?. fields ;
803813 if ( ! fields || typeof fields !== 'object' ) return ;
@@ -829,7 +839,7 @@ function validateNestedObjectFields(
829839
830840 // Check required fields
831841 if ( value === undefined || value === null ) {
832- if ( ! nestedField . isOptional ) {
842+ if ( ! nestedField . isOptional && ! options ?. allowMissingRequired ) {
833843 throw createRequiredFieldMissingError ( nestedField ) ;
834844 }
835845 continue ;
@@ -875,7 +885,11 @@ function validateNestedObjectFields(
875885 typeof value === 'object' &&
876886 ! Array . isArray ( value )
877887 ) {
878- validateNestedObjectFields ( nestedField , value as Record < string , unknown > ) ;
888+ validateNestedObjectFields (
889+ nestedField ,
890+ value as Record < string , unknown > ,
891+ options
892+ ) ;
879893 }
880894
881895 // Validate array of objects
@@ -889,7 +903,8 @@ function validateNestedObjectFields(
889903 if ( item && typeof item === 'object' ) {
890904 validateNestedObjectFields (
891905 nestedField ,
892- item as Record < string , unknown >
906+ item as Record < string , unknown > ,
907+ options
893908 ) ;
894909 }
895910 }
0 commit comments