Skip to content

Commit 52031cf

Browse files
committed
Enforce string length requirements
1 parent 4e8b406 commit 52031cf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,14 @@ 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 }
191192
if (typeof value !== "string") {
192193
errs.push("not a string");
194+
} else {
195+
if (value.length < min)
196+
errs.push("string too short");
197+
if (max && value.length > max)
198+
errs.push("string too long");
193199
}
194200
} else if (prop.type === "app") {
195201
const field = fields[prop.name]

0 commit comments

Comments
 (0)