File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
frontend/packages/pydantic-forms/src/components Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,7 @@ const defaultComponentMatchers: PydanticComponentMatcher[] = [
139139 field . options . length <= 5
140140 ) ;
141141 } ,
142+ validator : zodValidationPresets . array ,
142143 } ,
143144] ;
144145
Original file line number Diff line number Diff line change @@ -110,4 +110,25 @@ export const zodValidationPresets: PydanticFormZodValidationPresets = {
110110
111111 return validationRule ;
112112 } ,
113+ array : ( field ) => {
114+ const { minimum, maximum } = field ?. validation ?? { } ;
115+
116+ let arraySchema = z . array ( z . boolean ( ) ) ;
117+
118+ if ( minimum ) {
119+ arraySchema = arraySchema . min (
120+ minimum ,
121+ `Dit veld heeft een minimum waarde van ${ minimum } ` ,
122+ ) ;
123+ }
124+
125+ if ( maximum ) {
126+ arraySchema = arraySchema . max (
127+ maximum ,
128+ `Dit veld heeft een maximum waarde van ${ maximum } ` ,
129+ ) ;
130+ }
131+
132+ return arraySchema ;
133+ } ,
113134} ;
You can’t perform that action at this time.
0 commit comments