mirror of
https://github.com/transloadit/uppy.git
synced 2026-01-23 02:25:07 +00:00
@uppy/core: reject empty string as valid value for required meta fields (#3119)
This commit is contained in:
parent
3059d733f6
commit
0b801ccbad
2 changed files with 4 additions and 4 deletions
|
|
@ -555,14 +555,14 @@ class Uppy {
|
|||
*/
|
||||
#checkRequiredMetaFields (files) {
|
||||
const { requiredMetaFields } = this.opts.restrictions
|
||||
const { hasOwnProperty } = Object.prototype.hasOwnProperty
|
||||
const { hasOwnProperty } = Object.prototype
|
||||
|
||||
const errors = []
|
||||
const fileIDs = Object.keys(files)
|
||||
for (let i = 0; i < fileIDs.length; i++) {
|
||||
const file = this.getFile(fileIDs[i])
|
||||
for (let i = 0; i < requiredMetaFields.length; i++) {
|
||||
if (!hasOwnProperty.call(file.meta, requiredMetaFields[i])) {
|
||||
if (!hasOwnProperty.call(file.meta, requiredMetaFields[i]) || file.meta[requiredMetaFields[i]] === '') {
|
||||
const err = new RestrictionError(`${this.i18n('missingRequiredMetaFieldOnFile', { fileName: file.name })}`)
|
||||
errors.push(err)
|
||||
this.#showOrLogErrorAndThrow(err, { file, showInformer: false, throwErr: false })
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ uppy.use(Dashboard, {
|
|||
id: 'public',
|
||||
name: 'Public',
|
||||
render ({ value, onChange, required, form }, h) {
|
||||
return h('input', { type: 'checkbox', required, form, onChange: (ev) => onChange(ev.target.checked ? 'on' : 'off'), defaultChecked: value === 'on' })
|
||||
return h('input', { type: 'checkbox', required, form, onChange: (ev) => onChange(ev.target.checked ? 'on' : ''), defaultChecked: value === 'on' })
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
@ -272,7 +272,7 @@ uppy.use(Dashboard, {
|
|||
render: ({ value, onChange, required, form }, h) => {
|
||||
return h('input', {
|
||||
type: 'checkbox',
|
||||
onChange: (ev) => onChange(ev.target.checked ? 'on' : 'off'),
|
||||
onChange: (ev) => onChange(ev.target.checked ? 'on' : ''),
|
||||
defaultChecked: value === 'on',
|
||||
required,
|
||||
form,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue