Skip to content

cyclic import between validator and model packages #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spolti opened this issue Mar 7, 2023 · 6 comments · Fixed by #164
Closed

cyclic import between validator and model packages #151

spolti opened this issue Mar 7, 2023 · 6 comments · Fixed by #164
Assignees
Labels
enhancement 🙏 New feature or request

Comments

@spolti
Copy link
Member

spolti commented Mar 7, 2023

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.

@github-actions
Copy link

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.

@ricardozanini
Copy link
Member

@spolti is this still valid?

@spolti
Copy link
Member Author

spolti commented Apr 28, 2023

I am not sure, need to revisit it.

@github-actions
Copy link

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
Copy link
Member Author

spolti commented Jun 13, 2023

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

@ribeiromiranda
Copy link
Contributor

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

@ricardozanini ricardozanini linked a pull request Jun 13, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🙏 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants