File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
packages/connect-react/src/hooks Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -188,14 +188,21 @@ export const FormContextProvider = <T extends ConfigurableProps>({
188188 errs . push ( "not a boolean" ) ;
189189 }
190190 } else if ( prop . type === "string" ) {
191- const { min = 1 , max } = prop as unknown as { min ?: number , max ?: number }
191+ interface StringProp extends ConfigurableProp {
192+ min ?: number ;
193+ max ?: number ;
194+ }
195+ const { min = 0 , max } = prop as StringProp ;
192196 if ( typeof value !== "string" ) {
193197 errs . push ( "not a string" ) ;
194198 } else {
195- if ( value . length < min )
196- errs . push ( "string too short" ) ;
197- if ( max && value . length > max )
198- errs . push ( "string too long" ) ;
199+ if ( value . length < min ) {
200+ errs . push ( `string length must be at least ${ min } characters` ) ;
201+ }
202+ if ( max && value . length > max ) {
203+ errs . push ( `string length must not exceed ${ max } characters` ) ;
204+ }
205+ }
199206 }
200207 } else if ( prop . type === "app" ) {
201208 const field = fields [ prop . name ]
You can’t perform that action at this time.
0 commit comments