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', () => {
184
184
} ,
185
185
} ) ;
186
186
187
- it ( 'Returns undefined when no properties are passed' , ( ) => {
187
+ it ( 'Returns empty ZodObject when no properties are passed' , ( ) => {
188
188
const zodObject = getZodValidationObject ( { } , getMockMatcher ( ) ) ;
189
- const expectedZodObject = z . any ( ) ;
189
+ const expectedZodObject = z . object ( ) ;
190
190
expect ( z . toJSONSchema ( zodObject ) ) . toEqual (
191
191
z . toJSONSchema ( expectedZodObject ) ,
192
192
) ;
Original file line number Diff line number Diff line change @@ -82,8 +82,9 @@ export const getZodValidationObject = (
82
82
properties ,
83
83
componentMatcherExtender ,
84
84
) ;
85
+
85
86
if ( ! pydanticFormComponents || pydanticFormComponents . length === 0 )
86
- return z . any ( ) ;
87
+ return z . object ( ) ;
87
88
88
89
const validationObject : { [ k : string ] : z . ZodTypeAny } = { } ;
89
90
pydanticFormComponents . forEach ( ( component ) => {
@@ -104,7 +105,7 @@ export const getZodValidationObject = (
104
105
105
106
validationObject [ id ] = zodRule ?? z . any ( ) ;
106
107
} ) ;
107
- return validationObject ? z . object ( validationObject ) : z . any ( ) ;
108
+ return validationObject ? z . object ( validationObject ) : z . object ( ) ;
108
109
} ;
109
110
110
111
export const useGetZodSchema = (
@@ -113,8 +114,9 @@ export const useGetZodSchema = (
113
114
) : ZodObject | ZodAny => {
114
115
return useMemo ( ( ) => {
115
116
if ( ! pydanticFormSchema ) {
116
- return z . any ( ) ;
117
+ return z . object ( ) ;
117
118
}
119
+
118
120
// Get all fields ids including the nested ones to generate the correct validation schema
119
121
const validationObject = getZodValidationObject (
120
122
pydanticFormSchema . properties ,
You can’t perform that action at this time.
0 commit comments