Expect BB ref data as csv strings
This commit is contained in:
parent
adf5e6bcf2
commit
df97b7ad93
|
@ -43,3 +43,7 @@ export enum Format {
|
||||||
export function isFormat(format: any): format is Format {
|
export function isFormat(format: any): format is Format {
|
||||||
return Object.values(Format).includes(format as Format)
|
return Object.values(Format).includes(format as Format)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseCsvExport(value: string) {
|
||||||
|
return JSON.parse(value?.replace(/'/g, '"'))
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { FieldSubtype } from "@budibase/types"
|
||||||
import { FieldTypes } from "../constants"
|
import { FieldTypes } from "../constants"
|
||||||
import { ValidColumnNameRegex, utils } from "@budibase/shared-core"
|
import { ValidColumnNameRegex, utils } from "@budibase/shared-core"
|
||||||
import { db } from "@budibase/backend-core"
|
import { db } from "@budibase/backend-core"
|
||||||
|
import { parseCsvExport } from "../api/controllers/view/exporters"
|
||||||
|
|
||||||
interface SchemaColumn {
|
interface SchemaColumn {
|
||||||
readonly name: string
|
readonly name: string
|
||||||
|
@ -182,16 +183,22 @@ function isValidBBReference(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(columnData)) {
|
if (typeof columnData !== "string") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const castedData = parseCsvExport(columnData)
|
||||||
|
|
||||||
|
if (!Array.isArray(castedData)) {
|
||||||
// It must be an array field
|
// It must be an array field
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnSubtype === FieldSubtype.USER && columnData.length > 1) {
|
if (columnSubtype === FieldSubtype.USER && castedData.length > 1) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const d of columnData) {
|
for (const d of castedData) {
|
||||||
if (!db.isGlobalUserID(d._id)) {
|
if (!db.isGlobalUserID(d._id)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue