|
|
@ -190,6 +190,7 @@ function parseAndValidateFormula(formula: string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = new Set()) { |
|
|
|
function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = new Set()) { |
|
|
|
|
|
|
|
let type: formulaTypes; |
|
|
|
if (parsedTree.type === JSEPNode.CALL_EXP) { |
|
|
|
if (parsedTree.type === JSEPNode.CALL_EXP) { |
|
|
|
const calleeName = parsedTree.callee.name.toUpperCase() |
|
|
|
const calleeName = parsedTree.callee.name.toUpperCase() |
|
|
|
// validate function name |
|
|
|
// validate function name |
|
|
@ -207,6 +208,7 @@ function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = n |
|
|
|
errors.add(t('msg.formula.maxRequiredArgumentsFormula', { maxRequiredArguments: validation.args.max, calleeName })) |
|
|
|
errors.add(t('msg.formula.maxRequiredArgumentsFormula', { maxRequiredArguments: validation.args.max, calleeName })) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parsedTree.arguments.map((arg: Record<string, any>) => validateAgainstMeta(arg, errors)) |
|
|
|
parsedTree.arguments.map((arg: Record<string, any>) => validateAgainstMeta(arg, errors)) |
|
|
|
|
|
|
|
|
|
|
|
// validate data type |
|
|
|
// validate data type |
|
|
@ -445,7 +447,7 @@ function validateAgainstMeta(parsedTree: any, errors = new Set(), typeErrors = n |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
errors.add(t('msg.formula.cantSaveFieldFormulaInvalid')) |
|
|
|
errors.add(t('msg.formula.cantSaveFieldFormulaInvalid')) |
|
|
|
} |
|
|
|
} |
|
|
|
return errors |
|
|
|
return {errors, type} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function validateAgainstType(parsedTree: any, expectedType: string, func: any, typeErrors = new Set()) { |
|
|
|
function validateAgainstType(parsedTree: any, expectedType: string, func: any, typeErrors = new Set()) { |
|
|
|