From 7cd649ed4fd0eb2a838686a9ce84901362e893af Mon Sep 17 00:00:00 2001 From: Valentin Serra Date: Wed, 10 Apr 2024 18:41:01 +0200 Subject: [PATCH] wip: custom validation implementation --- packages/form-js-viewer/src/core/Validator.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/form-js-viewer/src/core/Validator.js b/packages/form-js-viewer/src/core/Validator.js index 4df86206d..a79f9072b 100644 --- a/packages/form-js-viewer/src/core/Validator.js +++ b/packages/form-js-viewer/src/core/Validator.js @@ -76,6 +76,15 @@ export class Validator { errors = runPresetValidation(field, evaluatedValidation, value, errors); + if ('custom' in evaluatedValidation && value && evaluatedValidation.custom.length) { + const { custom } = evaluatedValidation; + custom.forEach(({ condition, message }) => { + if (condition && !runExpressionEvaluation(this._expressionLanguage, value, expressionContextInfo)) { + errors = [...errors, message]; + } + }); + } + return errors; } } @@ -199,7 +208,7 @@ function oldEvaluateFEELValues(validate, expressionLanguage, conditionChecker, f // replace validate property with evaluated value if (evaluatedValue) { - set(evaluatedValidate, path, evaluatedValue); + set(validate, propertyPath.split('.'), evaluatedValue); } });