Type

AsyncConditionFunction

@ng-forge/dynamic-forms

Async function for conditions — returns boolean.

The function receives the evaluation context and may return a Promise or Observable. Register functions in customFnConfig.asyncConditions.

Signature

type AsyncConditionFunction<TFormValue extends Record<string, unknown> = any> = (
  context: EvaluationContext<unknown, TFormValue>,
) => Promise<boolean> | Observable<boolean>;

Type Parameters

NameConstraintDefaultDescription
TFormValueRecord<string, unknown>any-

Examples

const checkPermission: AsyncConditionFunction = async (context) => {
  const response = await fetch(`/api/permissions?user=${context.formValue.userId}`);
  const data = await response.json();
  return data.canEdit;
};