Skip to content

Commit 3924afc

Browse files
Update packages/connect-react/src/hooks/form-context.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6e17239 commit 3924afc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,21 @@ 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 }
191+
interface StringProp extends ConfigurableProp {
192+
min?: number;
193+
max?: number;
194+
}
195+
const { min = 0, max } = prop as StringProp;
192196
if (typeof value !== "string") {
193197
errs.push("not a string");
194198
} else {
195-
if (value.length < min)
196-
errs.push("string too short");
197-
if (max && value.length > max)
198-
errs.push("string too long");
199+
if (value.length < min) {
200+
errs.push(`string length must be at least ${min} characters`);
201+
}
202+
if (max && value.length > max) {
203+
errs.push(`string length must not exceed ${max} characters`);
204+
}
205+
}
199206
}
200207
} else if (prop.type === "app") {
201208
const field = fields[prop.name]

0 commit comments

Comments
 (0)