example

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package example is the fixture of the generator. Its generated file is committed, so the gate compiles and runs the code that the generator writes.

Every supported type and every rule of the SDD appears here one time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	// BoardID comes from the path, which wins over every other source.
	BoardID string `path:"board_id" validate:"required,uuid"`
	// Title comes from the form or from the body.
	Title string `json:"title" form:"title" validate:"required,min=3,max=50"`
	// Email covers the email rule.
	Email string `json:"email" form:"email" validate:"required,email"`
	// Role covers the oneof rule.
	Role string `json:"role" form:"role" validate:"oneof=admin member viewer"`
	// Page covers a signed integer and the numeric bounds.
	Page int `query:"page" validate:"min=1,max=100"`
	// Size covers a sized integer.
	Size int64 `query:"size"`
	// Ratio covers a float.
	Ratio float64 `query:"ratio"`
	// Notify covers a boolean. A boolean never carries the required rule.
	Notify bool `json:"notify" form:"notify" query:"notify"`
	// Timeout covers a duration.
	Timeout time.Duration `query:"timeout"`
	// StartsAt covers a time.
	StartsAt time.Time `query:"starts_at" json:"starts_at"`
	// Tags covers a repeated value.
	Tags []string `query:"tags" json:"tags"`
	// Computed binds from nothing. The handler fills it.
	Computed string `avero:"-"`
}

CreateInput covers every source and every rule.

func (*CreateInput) Bind

func (in *CreateInput) Bind(c *router.Ctx) error

Bind fills CreateInput from the request.

The sources are the JSON body, the form, the query and the path, in that order. A later source replaces an earlier one, so the path wins.

func (*CreateInput) Check

func (in *CreateInput) Check(_ *router.Ctx, f *router.Fields)

Check is the custom rule. The generated Validate calls it last, so it reads every field that the tags already checked.

func (*CreateInput) Validate

func (in *CreateInput) Validate(c *router.Ctx, f *router.Fields)

Validate checks CreateInput and records one message for each field that failed.

type ListInput

type ListInput struct {
	// Query comes from the query string only.
	Query string `query:"q" validate:"max=64"`
}

ListInput covers a type with no custom rule.

func (*ListInput) Bind

func (in *ListInput) Bind(c *router.Ctx) error

Bind fills ListInput from the request.

The sources are the JSON body, the form, the query and the path, in that order. A later source replaces an earlier one, so the path wins.

func (*ListInput) Validate

func (in *ListInput) Validate(c *router.Ctx, f *router.Fields)

Validate checks ListInput and records one message for each field that failed.

type Module

type Module struct{}

Module holds the handlers of the fixture.

func (*Module) Create

func (m *Module) Create(_ *router.Ctx, in CreateInput) (router.Response, error)

Create is a handler. The generator finds CreateInput from this signature.

func (*Module) List

func (m *Module) List(_ *router.Ctx, in ListInput) (router.Response, error)

List is a second handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL