We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Support command payload validation:
package auth type registerPayload struct { Name string Email string } func (payload registerPayload) Validate() error { if payload.Name == "" { return errors.New("empty name") } if !isValidEmail(payload.Email) { return fmt.Errorf("invalid email address: %s", payload.Email) } return nil } func RegisterUser(id uuid.UUID, name string, email string) command.Cmd[registerPayload] { return command.New("auth.user.register", registerPayload{name, email}, command.Aggregate("auth.user", id)) } func HandleCommands(ctx context.Context, bus command.Bus) <-chan error { return command.MustHandle(ctx, bus, "auth.user.register", func(ctx command.Context) error { // ... this will only execute if ctx.Payload() valid ... return nil }) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Support command payload validation:
The text was updated successfully, but these errors were encountered: