-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement instance validation in validator
Related to #1147
- Loading branch information
Showing
8 changed files
with
98 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/form-js-viewer/src/render/hooks/useTemplateEvaluation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { wrapObjectKeysWithUnderscores } from './simple'; | ||
|
||
|
||
/** | ||
* Transform a LocalExpressionContext object into a usable FEEL context. | ||
* | ||
* @param {Object} context - The LocalExpressionContext object. | ||
* @returns {Object} The usable FEEL context. | ||
*/ | ||
|
||
export function buildExpressionContext(context) { | ||
const { | ||
data, | ||
...specialContextKeys | ||
} = context; | ||
|
||
return { | ||
...specialContextKeys, | ||
...data, | ||
...wrapObjectKeysWithUnderscores(specialContextKeys) | ||
}; | ||
} | ||
|
||
/** | ||
* Evaluate a string based on the expressionLanguage and context information. | ||
* If the string is not an expression, it is returned as is. | ||
* | ||
* @param {any} expressionLanguage - The expression language to use. | ||
* @param {string} value - The string to evaluate. | ||
* @param {Object} expressionContextInfo - The context information to use. | ||
* @returns {any} - Evaluated value or the original value if not an expression. | ||
*/ | ||
export function runExpressionEvaluation(expressionLanguage, value, expressionContextInfo) { | ||
if (expressionLanguage && expressionLanguage.isExpression(value)) { | ||
return expressionLanguage.evaluate(value, buildExpressionContext(expressionContextInfo)); | ||
} | ||
return value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters