Skip to content

cyclic import between validator and model packages #151

@spolti

Description

@spolti

What would you like to be added:
Custom Structs, to be validated, needs to be registered in the validator in order to get executed.

Example:

type CallbackState struct {
    // Defines the action to be executed
    Action Action `json:"action" validate:"required"`

To get this validated, there is a need to register the custom struct here:
https://github.com/serverlessworkflow/sdk-go/blob/main/validator/validator.go#L28

Something similar to https://raw.githubusercontent.com/go-playground/validator/master/_examples/custom/main.go

But, the way that the packges are structured, it will lead to a cyclic import error:

package github.com/serverlessworkflow/sdk-go/v2/model
        imports github.com/serverlessworkflow/sdk-go/v2/validator
        imports github.com/serverlessworkflow/sdk-go/v2/model: import cycle not allowed

Why is this needed:

Allow custom structs to be validated.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions