Browse Source
Merge pull request #2707 from mslourens/fix_constraint_formula_field
Fix formula constraints check
pull/2729/head
Martin McKeaveney
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
0 deletions
-
packages/server/src/api/controllers/row/utils.js
|
|
|
@ -5,6 +5,7 @@ const { InternalTables } = require("../../../db/utils") |
|
|
|
const userController = require("../user") |
|
|
|
const { FieldTypes } = require("../../../constants") |
|
|
|
const { integrations } = require("../../../integrations") |
|
|
|
const { processStringSync } = require("@budibase/string-templates") |
|
|
|
|
|
|
|
validateJs.extend(validateJs.validators.datetime, { |
|
|
|
parse: function (value) { |
|
|
|
@ -73,6 +74,11 @@ exports.validate = async ({ appId, tableId, row, table }) => { |
|
|
|
errors[fieldName] = "Field not in list" |
|
|
|
} |
|
|
|
}) |
|
|
|
} else if (table.schema[fieldName].type === FieldTypes.FORMULA) { |
|
|
|
res = validateJs.single( |
|
|
|
processStringSync(table.schema[fieldName].formula, row), |
|
|
|
constraints |
|
|
|
) |
|
|
|
} else { |
|
|
|
res = validateJs.single(row[fieldName], constraints) |
|
|
|
} |
|
|
|
|