Condition<T>: {
    evaluate: ((subject: T, params?: unknown) => boolean);
    id: string;
    type: string;
}

Represents a conditional evaluation rule that can be registered and used throughout the application.

Conditions are predicate functions that determine whether certain UI elements should be visible, enabled, or available based on runtime state. For example, they can be used to:

  • Control action visibility (show/hide menu items based on object state)
  • Enable/disable features based on user permissions or context
  • Filter lists of items based on dynamic criteria
  • Implement business rules for conditional UI rendering

Each condition has a unique ID and a type that indicates what kind of subject it evaluates. The most common types are 'limeobject' and 'action', but custom types can be defined.

Example

Registering a simple LimeObject condition

const registry = platform.get(PlatformServiceName.ConditionRegistry);

const isDealWon = {
id: 'deal.is-won',
type: 'limeobject',
evaluate: (deal) => deal.dealstatus === 'won'
};

registry.addCondition(isDealWon);

Example

Condition with additional parameters

const hasMinimumValue = {
id: 'object.min-value',
type: 'limeobject',
evaluate: (object, params) => {
const { field, minValue } = params;
const value = object[field];
return typeof value === 'number' && value >= minValue;
}
};

const isHighValue = hasMinimumValue.evaluate(dealObject, {
field: 'value',
minValue: 100000
});

See

Type Parameters

  • T = unknown

Type declaration

  • evaluate: ((subject: T, params?: unknown) => boolean)
      • (subject: T, params?: unknown): boolean
      • The evaluation function that determines if the condition is met.

        This predicate function receives the subject to evaluate and optional parameters for configuration. It should return true if the condition is satisfied, false otherwise.

        The function should be pure and side-effect free when possible, as it may be called frequently during UI rendering and updates.

        Returns

        true if the condition is met, false otherwise.

        Throws

        May throw an error if params has an unexpected type or required data is missing.

        Example

        Simple boolean check

        const evaluate = (deal: LimeObject) => deal.dealstatus === 'won';
        

        Example

        Using params for configuration

        const evaluate = (obj: LimeObject, params?: { propertyName: string }) => {
        return obj.getValue(params.propertyName) !== null;
        };

        Parameters

        • subject: T

          The value to evaluate. Type depends on the condition type. For 'limeobject' conditions, this is a LimeObject. For 'action' conditions, this is an Action.

        • Optional params: unknown

          Optional configuration data for the evaluation. Can be used to pass context-specific values like field names, thresholds, or other criteria. The evaluation function should validate params if used.

        Returns boolean

  • id: string

    Unique identifier for this condition.

    The ID is used to reference the condition when registering, removing, or looking it up from the ConditionRegistry. It must be unique across all registered conditions.

  • type: string

    The type of subject this condition evaluates.

    Common types include:

    • limeobject - Evaluates LimeObject instances
    • action - Evaluates Action instances

    Custom types can be defined for specialized evaluation contexts.