Skip to content

Commit 47d1f69

Browse files
committed
fix file validation and check for max num of files
1 parent 854f710 commit 47d1f69

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/frontend/src/components/AttachmentSuggestions/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function AttachmentSuggestions(props: AttachmentSuggestionsProps) {
9595
if (!checked) {
9696
onChange?.(currentValues.filter((v: string) => v !== nameToCheck))
9797
} else {
98-
const { isValid, error } = validateFiles(variable, getValues(name))
98+
const { isValid, error } = validateFiles(variable, currentValues)
9999
if (!isValid) {
100100
setError(name, { type: 'invalidFile', message: error })
101101
} else {

packages/frontend/src/components/AttachmentSuggestions/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ export function validateFiles(
174174
const totalSize = currentTotalSize + fileSize
175175
const currentFileCount = selectedOptions.length + 1
176176

177-
if (currentFileCount >= MAX_NUM_FILES) {
177+
if (currentFileCount > MAX_NUM_FILES) {
178178
return {
179179
isValid: false,
180-
error: 'Total number of files exceeds 10',
180+
error: 'Total number of files cannot exceed 10',
181181
}
182182
}
183183
if (fileSize > MAX_FILE_SIZE) {

0 commit comments

Comments
 (0)