Skip to content

Commit 7cd649e

Browse files
committed
wip: custom validation implementation
1 parent 43dc6a0 commit 7cd649e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/form-js-viewer/src/core/Validator.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ export class Validator {
7676

7777
errors = runPresetValidation(field, evaluatedValidation, value, errors);
7878

79+
if ('custom' in evaluatedValidation && value && evaluatedValidation.custom.length) {
80+
const { custom } = evaluatedValidation;
81+
custom.forEach(({ condition, message }) => {
82+
if (condition && !runExpressionEvaluation(this._expressionLanguage, value, expressionContextInfo)) {
83+
errors = [...errors, message];
84+
}
85+
});
86+
}
87+
7988
return errors;
8089
}
8190
}
@@ -199,7 +208,7 @@ function oldEvaluateFEELValues(validate, expressionLanguage, conditionChecker, f
199208

200209
// replace validate property with evaluated value
201210
if (evaluatedValue) {
202-
set(evaluatedValidate, path, evaluatedValue);
211+
set(validate, propertyPath.split('.'), evaluatedValue);
203212
}
204213
});
205214

0 commit comments

Comments
 (0)