Skip to content

Commit 7e83dcb

Browse files
committed
quickfix for input values too short
1 parent 5257bd2 commit 7e83dcb

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

apps/web/src/modules/FormBuilder/errorMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const errorMessage = {
44
[QuestionTypes.shortAnswer]: {
55
required: "Required",
66
tooLong: "Value is too long",
7+
tooShort: "Value is too short",
78
},
89

910
[QuestionTypes.paragraph]: {

apps/web/src/modules/FormBuilder/questions/shortAnswer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const ShortAnswerQuestion = createQuestionItem({
1616
regex: z.string().optional(),
1717
validation: z
1818
.object({
19+
minLength: z.number(),
1920
maxLength: z.number(),
2021
email: z.boolean(),
2122
})
@@ -53,13 +54,21 @@ export const ShortAnswerQuestion = createQuestionItem({
5354
);
5455
}
5556

57+
if (typeof validation.minLength === "number") {
58+
schema = schema.min(validation.minLength, error.tooShort);
59+
}
60+
5661
if (typeof validation.maxLength === "number") {
5762
schema = schema.max(validation.maxLength, error.tooLong);
5863
}
5964

6065
return schema;
6166
}
6267

68+
if (typeof validation.minLength === "number") {
69+
schema = schema.min(validation.minLength, error.tooShort);
70+
}
71+
6372
if (typeof validation.maxLength === "number") {
6473
schema = schema.max(validation.maxLength, error.tooLong);
6574
}

0 commit comments

Comments
 (0)