• Creates a plugin that validates event data against a schema map.

    On dispatch, the event data is validated against the schema associated with the event name in the provided eventMapSchema. If no schema is defined for the event name, the data passes through without validation.

    When shouldValidateListeners is true (default), listener functions are also wrapped to validate event data before it reaches the listener. A WeakMap is used to track original-to-wrapped listener mappings so that removeListener correctly removes the wrapped listener.

    Parameters

    • settings: WithEventBusSchemaSettings

      Configuration for the schema validation.

      • eventMapSchema: EventMapSchema

        A map of event names to standard-schema-compliant schemas. Compatible with libraries such as Zod, ArkType, Valibot, and others that implement the StandardSchemaV1 specification.

      • OptionalshouldValidateListeners?: boolean

        Whether to validate event data in listener functions when events are received, in addition to validating on dispatch. When true, listeners will receive validated event data that conforms to the schema.

        true
        

    Returns PluginFn<IEventBusAdapter>

    A middleware plugin that wraps an IEventBusAdapter.

    IMPORT_PATH: "@daiso-tech/core/event-bus/plugins"

    true