diff --git a/components/onelogin/onelogin.app.mjs b/components/onelogin/onelogin.app.mjs index 61198508dd6b2..bc625b9d09792 100644 --- a/components/onelogin/onelogin.app.mjs +++ b/components/onelogin/onelogin.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/pennylane/pennylane.app.mjs b/components/pennylane/pennylane.app.mjs index 3fcf2a33cd18c..91b88847f1af9 100644 --- a/components/pennylane/pennylane.app.mjs +++ b/components/pennylane/pennylane.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/pingone/pingone.app.mjs b/components/pingone/pingone.app.mjs index 1f5bf022521eb..a10b29800fbb4 100644 --- a/components/pingone/pingone.app.mjs +++ b/components/pingone/pingone.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/packages/connect-react/CHANGELOG.md b/packages/connect-react/CHANGELOG.md index 15083925250d9..dc9225596572a 100644 --- a/packages/connect-react/CHANGELOG.md +++ b/packages/connect-react/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog +# [1.0.0-preview.10] - 2024-12-12 + +- Enforce string length limits + # [1.0.0-preview.9] - 2024-12-10 - Disabled submit button when form is incomplete diff --git a/packages/connect-react/package.json b/packages/connect-react/package.json index 8b8207854ccd8..d6d7388c8d590 100644 --- a/packages/connect-react/package.json +++ b/packages/connect-react/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/connect-react", - "version": "1.0.0-preview.9", + "version": "1.0.0-preview.10", "description": "Pipedream Connect library for React", "files": [ "dist" diff --git a/packages/connect-react/src/hooks/form-context.tsx b/packages/connect-react/src/hooks/form-context.tsx index 374203ca4d8fd..a13acc54e74b6 100644 --- a/packages/connect-react/src/hooks/form-context.tsx +++ b/packages/connect-react/src/hooks/form-context.tsx @@ -4,7 +4,7 @@ import { import isEqual from "lodash.isequal"; import { useQuery } from "@tanstack/react-query"; import type { - ComponentReloadPropsOpts, ConfigurableProp, ConfigurableProps, ConfiguredProps, V1Component, PropValue, + ComponentReloadPropsOpts, ConfigurableProp, ConfigurableProps, ConfiguredProps, V1Component, } from "@pipedream/sdk"; import { useFrontendClient } from "./frontend-client-context"; import type { ComponentFormProps } from "../components/ComponentForm"; @@ -166,7 +166,7 @@ export const FormContextProvider = ({ // these validations are necessary because they might override PropInput for number case for instance // so can't rely on that base control form validation - const propErrors = (prop: ConfigurableProp, value: unknown): string[] => { + const propErrors = (prop: ConfigurableProp, value: unknown): string[] => { const errs: string[] = []; if (value === undefined) { if (!prop.optional) { @@ -188,14 +188,31 @@ export const FormContextProvider = ({ errs.push("not a boolean"); } } else if (prop.type === "string") { + type StringProp = ConfigurableProp & { + min?: number; + max?: number; + } + const { + min = 1, max, + } = prop as StringProp; if (typeof value !== "string") { errs.push("not a string"); + } else { + if (value.length < min) { + errs.push(`string length must be at least ${min} characters`); + } + if (max && value.length > max) { + errs.push(`string length must not exceed ${max} characters`); + } } } else if (prop.type === "app") { const field = fields[prop.name] if (field) { const app = field.extra.app - const err = appPropError({ value, app }) + const err = appPropError({ + value, + app, + }) if (err) errs.push(err) } else { errs.push("field not registered")