Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/onelogin/onelogin.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/pennylane/pennylane.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/pingone/pingone.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
4 changes: 4 additions & 0 deletions packages/connect-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<!-- markdownlint-disable MD024 -->
# 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
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
23 changes: 20 additions & 3 deletions packages/connect-react/src/hooks/form-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -166,7 +166,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({

// 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 = <T extends ConfigurableProps>(prop: ConfigurableProp, value: unknown): string[] => {
const propErrors = (prop: ConfigurableProp, value: unknown): string[] => {
const errs: string[] = [];
if (value === undefined) {
if (!prop.optional) {
Expand All @@ -188,14 +188,31 @@ export const FormContextProvider = <T extends ConfigurableProps>({
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")
Expand Down
Loading