44import isEqual from "lodash.isequal" ;
55import { useQuery } from "@tanstack/react-query" ;
66import type {
7- ComponentReloadPropsOpts , ConfigurableProp , ConfigurableProps , ConfiguredProps , V1Component , PropValue ,
7+ ComponentReloadPropsOpts , ConfigurableProp , ConfigurableProps , ConfiguredProps , V1Component ,
88} from "@pipedream/sdk" ;
99import { useFrontendClient } from "./frontend-client-context" ;
1010import type { ComponentFormProps } from "../components/ComponentForm" ;
@@ -166,7 +166,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
166166
167167 // these validations are necessary because they might override PropInput for number case for instance
168168 // so can't rely on that base control form validation
169- const propErrors = < T extends ConfigurableProps > ( prop : ConfigurableProp , value : unknown ) : string [ ] => {
169+ const propErrors = ( prop : ConfigurableProp , value : unknown ) : string [ ] => {
170170 const errs : string [ ] = [ ] ;
171171 if ( value === undefined ) {
172172 if ( ! prop . optional ) {
@@ -188,14 +188,31 @@ export const FormContextProvider = <T extends ConfigurableProps>({
188188 errs . push ( "not a boolean" ) ;
189189 }
190190 } else if ( prop . type === "string" ) {
191+ type StringProp = ConfigurableProp & {
192+ min ?: number ;
193+ max ?: number ;
194+ }
195+ const {
196+ min = 1 , max,
197+ } = prop as StringProp ;
191198 if ( typeof value !== "string" ) {
192199 errs . push ( "not a string" ) ;
200+ } else {
201+ if ( value . length < min ) {
202+ errs . push ( `string length must be at least ${ min } characters` ) ;
203+ }
204+ if ( max && value . length > max ) {
205+ errs . push ( `string length must not exceed ${ max } characters` ) ;
206+ }
193207 }
194208 } else if ( prop . type === "app" ) {
195209 const field = fields [ prop . name ]
196210 if ( field ) {
197211 const app = field . extra . app
198- const err = appPropError ( { value, app } )
212+ const err = appPropError ( {
213+ value,
214+ app,
215+ } )
199216 if ( err ) errs . push ( err )
200217 } else {
201218 errs . push ( "field not registered" )
0 commit comments