Skip to content

Commit 2b422d2

Browse files
adolfo-pdTheBestMoshecoderabbitai[bot]
authored
fix: Enforce string limits (#14953)
Co-authored-by: Moshe Grunwald <34072688+TheBestMoshe@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent f287f30 commit 2b422d2

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

components/onelogin/onelogin.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/pennylane/pennylane.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/pingone/pingone.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

packages/connect-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.10] - 2024-12-12
5+
6+
- Enforce string length limits
7+
48
# [1.0.0-preview.9] - 2024-12-10
59

610
- Disabled submit button when form is incomplete

packages/connect-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.0.0-preview.9",
3+
"version": "1.0.0-preview.10",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"

packages/connect-react/src/hooks/form-context.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
import isEqual from "lodash.isequal";
55
import { useQuery } from "@tanstack/react-query";
66
import type {
7-
ComponentReloadPropsOpts, ConfigurableProp, ConfigurableProps, ConfiguredProps, V1Component, PropValue,
7+
ComponentReloadPropsOpts, ConfigurableProp, ConfigurableProps, ConfiguredProps, V1Component,
88
} from "@pipedream/sdk";
99
import { useFrontendClient } from "./frontend-client-context";
1010
import 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

Comments
 (0)