🌐 AI搜索 & 代理 主页
Skip to content

Commit 498a262

Browse files
fix(b-form-file): fix value prop validation when using directory mode (fixes #4912) (#4913)
* fix(b-form-file): fix value prop validation when using directory mode Fixes #4912 * Update form-file.js * Update form-file.js * Update form-file.js * Update form-file.js * Update form-file.js * Update form-file.js * Update form-file.js Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
1 parent d567ceb commit 498a262

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/form-file/form-file.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ import formStateMixin from '../../mixins/form-state'
1212
import idMixin from '../../mixins/id'
1313
import normalizeSlotMixin from '../../mixins/normalize-slot'
1414

15+
// --- Constants ---
16+
1517
const NAME = 'BFormFile'
1618

1719
const VALUE_EMPTY_DEPRECATED_MSG =
1820
'Setting "value"/"v-model" to an empty string for reset is deprecated. Set to "null" instead.'
1921

22+
// --- Helper methods ---
23+
24+
const isValidValue = value => isFile(value) || (isArray(value) && value.every(v => isValidValue(v)))
25+
2026
// @vue/component
2127
export const BFormFile = /*#__PURE__*/ Vue.extend({
2228
name: NAME,
@@ -34,17 +40,13 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
3440
value: {
3541
type: [File, Array],
3642
default: null,
37-
validator: val => {
43+
validator: value => {
3844
/* istanbul ignore next */
39-
if (val === '') {
45+
if (value === '') {
4046
warn(VALUE_EMPTY_DEPRECATED_MSG, NAME)
4147
return true
4248
}
43-
return (
44-
isUndefinedOrNull(val) ||
45-
isFile(val) ||
46-
(isArray(val) && (val.length === 0 || val.every(isFile)))
47-
)
49+
return isUndefinedOrNull(value) || isValidValue(value)
4850
}
4951
},
5052
accept: {

0 commit comments

Comments
 (0)