serverlessworkflow/sdk-go

cyclic import between validator and model packages

spolti opened this issue · 6 comments

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.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@spolti is this still valid?

spolti commented

I am not sure, need to revisit it.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

spolti commented

@ribeiromiranda Hi, it seems that your last PR is going to address this problem, can you please confirm?

@spolti Yes. Solve this problem.
The register the custom struct now is inside package model in files *_validator.go.