This commit is contained in:
Adria Navarro 2023-10-10 14:20:26 +02:00
parent e473c8b3a8
commit 78335be26a
1 changed files with 7 additions and 18 deletions

View File

@ -196,33 +196,22 @@ function isValidBBReference(
switch (columnSubtype) { switch (columnSubtype) {
case FieldSubtype.USER: case FieldSubtype.USER:
case FieldSubtype.USERS: case FieldSubtype.USERS:
if (!columnData) {
// Empty columns are valid by default
return true
}
if (typeof columnData !== "string") { if (typeof columnData !== "string") {
return false return false
} }
const userArray = parseCsvExport<{ _id: string }[]>(columnData)
const castedData = parseCsvExport(columnData) if (columnSubtype === FieldSubtype.USER && userArray.length > 1) {
if (!Array.isArray(castedData)) {
// It must be an array field
return false return false
} }
if (columnSubtype === FieldSubtype.USER && castedData.length > 1) { if (!Array.isArray(columnData)) {
return false return false
} }
for (const d of castedData) { const constainsWrongId = userArray.find(
if (!db.isGlobalUserID(d._id)) { user => !db.isGlobalUserID(user._id)
return false )
} return !constainsWrongId
}
return true
default: default:
throw utils.unreachable(columnSubtype) throw utils.unreachable(columnSubtype)