File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
frontend/packages/pydantic-forms/src/core/hooks Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -184,9 +184,9 @@ describe('getZodValidationObject', () => {
184184 } ,
185185 } ) ;
186186
187- it ( 'Returns undefined when no properties are passed' , ( ) => {
187+ it ( 'Returns empty ZodObject when no properties are passed' , ( ) => {
188188 const zodObject = getZodValidationObject ( { } , getMockMatcher ( ) ) ;
189- const expectedZodObject = z . any ( ) ;
189+ const expectedZodObject = z . object ( ) ;
190190 expect ( z . toJSONSchema ( zodObject ) ) . toEqual (
191191 z . toJSONSchema ( expectedZodObject ) ,
192192 ) ;
Original file line number Diff line number Diff line change @@ -82,8 +82,9 @@ export const getZodValidationObject = (
8282 properties ,
8383 componentMatcherExtender ,
8484 ) ;
85+
8586 if ( ! pydanticFormComponents || pydanticFormComponents . length === 0 )
86- return z . any ( ) ;
87+ return z . object ( ) ;
8788
8889 const validationObject : { [ k : string ] : z . ZodTypeAny } = { } ;
8990 pydanticFormComponents . forEach ( ( component ) => {
@@ -104,7 +105,7 @@ export const getZodValidationObject = (
104105
105106 validationObject [ id ] = zodRule ?? z . any ( ) ;
106107 } ) ;
107- return validationObject ? z . object ( validationObject ) : z . any ( ) ;
108+ return validationObject ? z . object ( validationObject ) : z . object ( ) ;
108109} ;
109110
110111export const useGetZodSchema = (
@@ -113,8 +114,9 @@ export const useGetZodSchema = (
113114) : ZodObject | ZodAny => {
114115 return useMemo ( ( ) => {
115116 if ( ! pydanticFormSchema ) {
116- return z . any ( ) ;
117+ return z . object ( ) ;
117118 }
119+
118120 // Get all fields ids including the nested ones to generate the correct validation schema
119121 const validationObject = getZodValidationObject (
120122 pydanticFormSchema . properties ,
You can’t perform that action at this time.
0 commit comments