Skip to content

Allow for validation hooks #93

Open
@xibz

Description

@xibz

So this kind of depends on #92

But right now we have these if statements that do validation based on an if type check.

if t, ok := event.(SomeBusV5) {
}

However, if we add v6, v7, v8, this if statement will just keep growing. The handler pattern works really well here.

var defaultHandlers CDEventClientHandlers = NewCDEventClientHandlers()
    .Add("v5-validation", SomeBusV5Validator)

// then when users create clients we can just inject the default handlers
func NewCDEventsClient(ctx context.Context, options ...CDEventClientOption) (*CDEventsClient, err) {
    client := &CDEventsClient {
        ClientHandlers: defaultHandlers,
    }
    return client
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions