Skip to content

Commit

Permalink
wip: custom validation implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaiir committed Apr 17, 2024
1 parent 43dc6a0 commit 7cd649e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/form-js-viewer/src/core/Validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
}
});

Expand Down

0 comments on commit 7cd649e

Please sign in to comment.