Skip to content
Permalink
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>
  • Loading branch information
tmorehouse and jacobmllr95 committed Mar 9, 2020
1 parent d567ceb commit 498a26219571bb6108aaa7134dc25c8e1ff6c98f
Showing 1 changed file with 9 additions and 7 deletions.
@@ -12,11 +12,17 @@ import formStateMixin from '../../mixins/form-state'
import idMixin from '../../mixins/id'
import normalizeSlotMixin from '../../mixins/normalize-slot'

// --- Constants ---

const NAME = 'BFormFile'

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

// --- Helper methods ---

const isValidValue = value => isFile(value) || (isArray(value) && value.every(v => isValidValue(v)))

// @vue/component
export const BFormFile = /*#__PURE__*/ Vue.extend({
name: NAME,
@@ -34,17 +40,13 @@ export const BFormFile = /*#__PURE__*/ Vue.extend({
value: {
type: [File, Array],
default: null,
validator: val => {
validator: value => {
/* istanbul ignore next */
if (val === '') {
if (value === '') {
warn(VALUE_EMPTY_DEPRECATED_MSG, NAME)
return true
}
return (
isUndefinedOrNull(val) ||
isFile(val) ||
(isArray(val) && (val.length === 0 || val.every(isFile)))
)
return isUndefinedOrNull(value) || isValidValue(value)
}
},
accept: {

0 comments on commit 498a262

Please sign in to comment.