1
0
Fork 0
mirror of synced 2024-10-03 02:27:06 +13:00

Merge branch 'bug/relationship-display-id' of github.com:Budibase/budibase into bug/relationship-display-id

This commit is contained in:
Andrew Kingston 2021-02-25 11:16:08 +00:00
commit fcdbbe2634
2 changed files with 11 additions and 5 deletions

View file

@ -15,6 +15,7 @@ const {
} = require("../../utilities/rowProcessor") } = require("../../utilities/rowProcessor")
const { FieldTypes } = require("../../constants") const { FieldTypes } = require("../../constants")
const { isEqual } = require("lodash") const { isEqual } = require("lodash")
const { cloneDeep } = require("lodash/fp")
const TABLE_VIEW_BEGINS_WITH = `all${SEPARATOR}${DocumentTypes.TABLE}${SEPARATOR}` const TABLE_VIEW_BEGINS_WITH = `all${SEPARATOR}${DocumentTypes.TABLE}${SEPARATOR}`
@ -351,10 +352,15 @@ async function validate({ appId, tableId, row, table }) {
} }
const errors = {} const errors = {}
for (let fieldName of Object.keys(table.schema)) { for (let fieldName of Object.keys(table.schema)) {
const res = validateJs.single( const constraints = cloneDeep(table.schema[fieldName].constraints)
row[fieldName], // special case for options, need to always allow unselected (null)
table.schema[fieldName].constraints if (
) table.schema[fieldName].type === FieldTypes.OPTIONS &&
constraints.inclusion
) {
constraints.inclusion.push(null)
}
const res = validateJs.single(row[fieldName], constraints)
if (res) errors[fieldName] = res if (res) errors[fieldName] = res
} }
return { valid: Object.keys(errors).length === 0, errors } return { valid: Object.keys(errors).length === 0, errors }

View file

@ -25,7 +25,7 @@ const TYPE_TRANSFORM_MAP = {
}, },
}, },
[FieldTypes.OPTIONS]: { [FieldTypes.OPTIONS]: {
"": "", "": null,
[null]: "", [null]: "",
[undefined]: undefined, [undefined]: undefined,
}, },