formtask

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefineCheckboxForm added in v0.60.1

func DefineCheckboxForm(id taskid.TaskImplementationID[bool], priority int, label string, description string, bind func(b *coretask.Binder) CheckboxFormSpec, labelOpts ...coretask.LabelOpt) coretask.Task[bool]

DefineCheckboxForm defines a checkbox form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.

func DefineFileForm added in v0.60.1

func DefineFileForm(id taskid.TaskImplementationID[upload.UploadResult], priority int, label string, description string, verifier upload.UploadFileVerifier, labelOpts ...coretask.LabelOpt) coretask.Task[upload.UploadResult]

DefineFileForm defines a form task that receives a file uploaded by the user and returns the upload result. verifier checks the uploaded file. The form reads no input, so it declares nothing on the Binder.

func DefineSetForm added in v0.60.1

func DefineSetForm[T any](id taskid.TaskImplementationID[T], priority int, label string, description string, bind func(b *coretask.Binder) SetFormSpec[T], labelOpts ...coretask.LabelOpt) coretask.Task[T]

DefineSetForm defines a set form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.

func DefineTextForm added in v0.60.1

func DefineTextForm[T any](id taskid.TaskImplementationID[T], priority int, label string, description string, bind func(b *coretask.Binder) TextFormSpec[T], labelOpts ...coretask.LabelOpt) coretask.Task[T]

DefineTextForm defines a text form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.

func GenerateUploadIDWithTaskContext

func GenerateUploadIDWithTaskContext(ctx context.Context, formId string) string

GenerateUploadIDWithTaskContext generates the upload ID from form ID and task ID.

Types

type CheckboxFormDefaultValueGenerator added in v0.59.0

type CheckboxFormDefaultValueGenerator = func(ctx context.Context) (bool, error)

CheckboxFormDefaultValueGenerator generates the default checked state for the checkbox.

type CheckboxFormHintGenerator added in v0.59.0

type CheckboxFormHintGenerator = func(ctx context.Context, value bool) (string, inspectionmetadata.ParameterHintType, error)

CheckboxFormHintGenerator generates a hint message and its severity type for the checkbox field.

type CheckboxFormReadonlyProvider added in v0.59.0

type CheckboxFormReadonlyProvider = func(ctx context.Context) (bool, error)

CheckboxFormReadonlyProvider determines whether the checkbox should be disabled/readonly.

type CheckboxFormSpec added in v0.60.1

type CheckboxFormSpec struct {
	// Readonly reports whether the field is read only. Defaults to false.
	Readonly CheckboxFormReadonlyProvider
	// DefaultValue generates the default checked state. Defaults to false.
	DefaultValue CheckboxFormDefaultValueGenerator
	// Validator validates the checked state. Defaults to a validator that accepts any value.
	Validator CheckboxFormValidator
	// Hint generates a hint message for the form field. Defaults to no hint.
	Hint CheckboxFormHintGenerator
}

CheckboxFormSpec holds the optional settings of a checkbox form defined with DefineCheckboxForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback uses the default.

type CheckboxFormValidator added in v0.59.0

type CheckboxFormValidator = func(ctx context.Context, value bool) (string, error)

CheckboxFormValidator validates whether the given boolean value is valid. Returns an empty string when valid, or an error message to display on the frontend. The second return value is used for unrecoverable errors during validation.

type SetFormBoolProvider added in v0.51.0

type SetFormBoolProvider = func(ctx context.Context) (bool, error)

SetFormBoolProvider is a function type to provide boolean flags dynamically.

func ConstantBool added in v0.60.1

func ConstantBool(value bool) SetFormBoolProvider

ConstantBool returns a SetFormBoolProvider that always returns value.

type SetFormDefaultValueGenerator added in v0.51.0

type SetFormDefaultValueGenerator = func(ctx context.Context, previousValues []string) ([]string, error)

SetFormDefaultValueGenerator is a function type to generate the default value.

func PreviousOrConstantDefaultValue added in v0.60.1

func PreviousOrConstantDefaultValue(values []string) SetFormDefaultValueGenerator

PreviousOrConstantDefaultValue returns a SetFormDefaultValueGenerator that returns the previous values when they exist, otherwise values.

type SetFormHintGenerator added in v0.51.0

type SetFormHintGenerator = func(ctx context.Context, value []string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error)

SetFormHintGenerator is a function type to generate a hint string

type SetFormOptionsProvider added in v0.51.0

type SetFormOptionsProvider = func(ctx context.Context, previousValues []string) ([]inspectionmetadata.SetParameterFormFieldOptionItem, error)

SetFormOptionsProvider is a function to return the list of options.

func ConstantOptions added in v0.60.1

ConstantOptions returns a SetFormOptionsProvider that always returns options.

type SetFormSpec added in v0.60.1

type SetFormSpec[T any] struct {
	// AllowCustomValue reports whether users can input custom values. Defaults to false.
	AllowCustomValue SetFormBoolProvider
	// DisableAddAll reports whether the "Add All" option is disabled. Defaults to false.
	DisableAddAll SetFormBoolProvider
	// DisableRemoveAll reports whether the "Remove All" option is disabled. Defaults to false.
	DisableRemoveAll SetFormBoolProvider
	// DefaultValue generates the default value of the set form. Defaults to nil.
	DefaultValue SetFormDefaultValueGenerator
	// Options provides the available options for the set form. Defaults to an empty slice.
	Options SetFormOptionsProvider
	// Validator validates the input string slice. Defaults to a validator that accepts any input.
	Validator SetFormValidator
	// Converter converts the input string slice to T. Defaults to a conversion that only works when T is []string.
	Converter SetFormValueConverter[T]
	// Hint generates a hint message for the form field. Defaults to no hint.
	Hint SetFormHintGenerator
}

SetFormSpec holds the optional settings of a set form defined with DefineSetForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback or a zero value uses the default.

type SetFormValidator added in v0.51.0

type SetFormValidator = func(ctx context.Context, value []string) (string, error)

SetFormValidator is a function to check if the given value is valid or not.

type SetFormValueConverter added in v0.51.0

type SetFormValueConverter[T any] = func(ctx context.Context, value []string) (T, error)

SetFormValueConverter is a function type to convert the given string slice value to another type stored in the variable set.

type TextFormDefaultValueGenerator

type TextFormDefaultValueGenerator = func(ctx context.Context, previousValues []string) (string, error)

TextFormDefaultValueGenerator is a function type to generate the default value.

func PreviousOrDefaultValue added in v0.60.1

func PreviousOrDefaultValue(defaultValue func(ctx context.Context) (string, error)) TextFormDefaultValueGenerator

PreviousOrDefaultValue returns a TextFormDefaultValueGenerator that returns the most recent previous value when one exists, or calls defaultValue to compute the initial default value.

type TextFormHintGenerator

type TextFormHintGenerator = func(ctx context.Context, value string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error)

TextFormHintGenerator is a function type to generate a hint string

type TextFormReadonlyProvider

type TextFormReadonlyProvider = func(ctx context.Context) (bool, error)

TextFormReadonlyProvider is a function type to compute if the field is allowed edit or not.

type TextFormSpec added in v0.60.1

type TextFormSpec[T any] struct {
	// Readonly reports whether the field is read only. Defaults to false.
	Readonly TextFormReadonlyProvider
	// DefaultValue generates the default value of the text form. Defaults to empty string.
	DefaultValue TextFormDefaultValueGenerator
	// Suggestions provides suggestions for the text form. Defaults to nil.
	Suggestions TextFormSuggestionsProvider
	// Validator validates the input string. Defaults to a validator that accepts any string.
	Validator TextFormValidator
	// Converter converts the input string to T. Defaults to a conversion that only works when T is string.
	Converter TextFormValueConverter[T]
	// Hint generates a hint message for the form field. Defaults to no hint.
	Hint TextFormHintGenerator
	// ValidationTiming specifies when form validation should occur. Defaults to inspectionmetadata.Change.
	ValidationTiming inspectionmetadata.TextFormValidationTimingType
}

TextFormSpec holds the optional settings of a text form defined with DefineTextForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback or a zero value uses the default.

type TextFormSuggestionsProvider

type TextFormSuggestionsProvider = func(ctx context.Context, value string, previousValues []string) ([]string, error)

TextFormSuggestionsProvider is a function to return the list of strings shown in the autocomplete. Return nil instead of empty string array means the autocomplete is disabled for the field.

func ConstantSuggestions added in v0.60.1

func ConstantSuggestions(suggestions ...string) TextFormSuggestionsProvider

ConstantSuggestions returns a suggestions provider that always returns the given suggestions.

type TextFormValidator

type TextFormValidator = func(ctx context.Context, value string) (string, error)

TextFormValidator is a function to check if the given value is valid or not. Returns "" as the result when it has no error, otherwise the returned value is used as an error message on frontend. Returning an error as the 2nd returning value is only when the validator detects an unrecoverble error.

type TextFormValueConverter

type TextFormValueConverter[T any] = func(ctx context.Context, value string) (T, error)

TextFormValueConverter is a function type to convert the given string value to another type stored in the variable set.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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