How to add CustomConditions

Hallo,

I want to add a CustomConditions to the FormEngine. I tried it like this, but it doesn’t worked (while validating the rule, which uses the CustomCondition, the Engine couldn’t found it):

const customConditions: ((state: EngineState) => CustomConditionsMap) =
          () =>
			({
				CustomConditionName: {
					check(
						data: IData,
						relevantEntities: Set<IIdentifier> | undefined,
						formallyIncorrectFields: Set<IIdentifier>,
						errorField: IIdentifier
					) {
						// doSomething and return boolen
					}
				}
			});
const config = ApplicationFactories.createApplicationSetup({
		...,
		additionalMiddlewares: [
                                    ...createEngineMiddlewares({ converter: customConverters(), customConditions: customConditions }),
			...createBapFormEngineMiddlewares(),
			...
		],
...});

Has anyone experience with CustomConditions and have a hint for me or can help me to found out, what is wrong?

Best regards
Nora

Hi Nora, there seems to be a typo. Can you try again with customConditions?

Morning Baschir,

Oh, I didn’t recognized the typo, when I wrote the thread. But the typo is only in the thread. I didn’t Copy/Pasted it directly from my source code.
Sorry for the confusion.

I corrected the typo in the thread.
Supplement:

I would have expected an attribute in the engine config, like for “externalEnumerationProvider” and “converter”, but I didn’t found anything which seams to fit.

Please have a look at this working example:

<INTERNAL_LINK>

<INTERNAL_LINK>

If that doesn’t help I suggest to do a debugging session :slight_smile:

Hi Baschir,

thanks for your answer.
My attempt based on that example.

The problem was, that we have overridden the FormEngineMiddleware, after setting it with the customConditions.
Now it works like in the example.