form

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	Label       string             `yaml:"label,omitempty"`
	Description string             `yaml:"description,omitempty"`
	Placeholder string             `yaml:"placeholder,omitempty"`
	Value       string             `yaml:"value,omitempty"`
	Render      string             `yaml:"render,omitempty"`
	Multiple    bool               `yaml:"multiple,omitempty"`
	Options     []CheckboxOrString `yaml:"options,omitempty"`
	Default     int                `yaml:"default,omitempty"`
}

Attributes holds element attributes. https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema

type CheckboxOrString

type CheckboxOrString struct {
	Label    string
	Required bool
	Hidden   bool
}

CheckboxOrString carries:

  • either a plain string (dropdown option)
  • or a checkbox option object (label + required).

func (*CheckboxOrString) UnmarshalYAML

func (o *CheckboxOrString) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML supports both shapes for option entries:

  • dropdown style: "Some option"
  • checkbox style: { label: "...", required: ... }

type Element

type Element struct {
	Type        string      `yaml:"type"`
	ID          string      `yaml:"id,omitempty"`
	Attributes  Attributes  `yaml:"attributes,omitempty"`
	Validations Validations `yaml:"validations,omitempty"`
}

Element represents a single body element of any kind. https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema

type Form

type Form struct {
	Slug     string `yaml:"-"`
	Filename string `yaml:"-"`

	Name        string        `yaml:"name"`
	Description string        `yaml:"description"`
	Body        []*Element    `yaml:"body"`
	Assignees   StringOrSlice `yaml:"assignees,omitempty"`
	Labels      StringOrSlice `yaml:"labels,omitempty"`
	Title       string        `yaml:"title,omitempty"`
	Type        string        `yaml:"type,omitempty"`
	Projects    StringOrSlice `yaml:"projects,omitempty"`
}

Form represents a GitHub issue form definition. https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

func New

func New() (*Loader, error)

func (*Loader) Load

func (l *Loader) Load(dir string) ([]*Form, error)

Load reads all issue forms from a directory, validates them against the embedded JSON schema, and returns them sorted by file name.

Files named `config.yml` and `config.yaml` are skipped: they are issue chooser configurations, not forms.

type SchemaValidator

type SchemaValidator struct {
	// contains filtered or unexported fields
}

func NewSchemaChooserValidator

func NewSchemaChooserValidator() (*SchemaValidator, error)

func NewSchemaDiscussionValidator

func NewSchemaDiscussionValidator() (*SchemaValidator, error)

func NewSchemaIssueValidator

func NewSchemaIssueValidator() (*SchemaValidator, error)

type StringOrSlice

type StringOrSlice []string

StringOrSlice array or comma-delimited string.

func (*StringOrSlice) UnmarshalYAML

func (s *StringOrSlice) UnmarshalYAML(value *yaml.Node) error

type Validations

type Validations struct {
	Required bool   `yaml:"required,omitempty"`
	Accept   string `yaml:"accept,omitempty"`
}

Validations holds element validation rules. https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema

Jump to

Keyboard shortcuts

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