Skip to content
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

Can't have a custom type be the input to a controller action #260

Open
jfmario opened this issue Aug 26, 2022 · 2 comments
Open

Can't have a custom type be the input to a controller action #260

jfmario opened this issue Aug 26, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@jfmario
Copy link
Contributor

jfmario commented Aug 26, 2022

With the following controller:

package route171

import (
	"errors"
	"strings"
)

type Controller struct {
	// Dependencies...
}

type Email string

func (email Email) Validate() error {
	if !strings.Contains(string(email), "@") {
		return errors.New("Not a valid email.")
	}
	return nil
}

func (c *Controller) Index(email Email) []string {
	return []string{}
}

There is the following error:

genfs: error generating "bud/internal/app/controller/controller.go". controller: unable to load: controller: unable to find param definition for Email. parser: unable to find declaration for "Email" in "route171"
exit status 1

This came up when I was working on issue #171

I'll take a look at what is going on, but I wanted to put this issue in for tracking it since it's separate.

@jfmario
Copy link
Contributor Author

jfmario commented Aug 26, 2022

So, here is where it needs to be handled: https://github.com/livebud/bud/blob/main/package/parser/definition.go#L23

I've been looking into it, but so far I'm at a bit of a loss as to what has happen here... other than that the value of decl has to be set to something that the bud parser will understand.

@matthewmueller
Copy link
Contributor

Thanks @jfmario! This is indeed a known issue. I'll try to push up a fix soon to unblock you, but otherwise feel free to wrap up the other PR on just with just struct support and we'll get to this later!

@matthewmueller matthewmueller added the bug Something isn't working label Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants